From 0b1716e5cde58e829153fdbd181b7f66f1f51a35 Mon Sep 17 00:00:00 2001 From: Eric Keller Date: Sat, 2 Sep 2017 19:28:53 +0200 Subject: [PATCH] only check connectivity when an update is needed --- tools/check_for_upgrade.sh | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh index 88085f8a6..965613592 100644 --- a/tools/check_for_upgrade.sh +++ b/tools/check_for_upgrade.sh @@ -11,6 +11,18 @@ function _update_zsh_update() { } function _upgrade_zsh() { + # Skip when no internet connectivity, depends on curl + REMOTE=$(cd "$ZSH" && git remote get-url --all origin) + echo "$REMOTE" | grep -qa 'git@' + if [ $? -eq 0 ] + then + # convert the remote protocol to https + REMOTE=$(echo $REMOTE | tr ':' '/' | sed -e "s#git@#https://#") + fi + + # -L follow redirect, -s silent, + # --max-time overall operation timeout, -I only download headers + whence curl > /dev/null && curl -L -s --max-time 3 -I ${REMOTE} > /dev/null || return 0 env ZSH=$ZSH sh $ZSH/tools/upgrade.sh # update the zsh file _update_zsh_update @@ -29,18 +41,6 @@ fi # Cancel upgrade if git is unavailable on the system whence git >/dev/null || return 0 -# Skip when no internet connectivity, depends on curl -REMOTE=$(cd "$ZSH" && git remote get-url --all origin) -echo "$REMOTE" | grep -qa 'git@' -if [ $? -eq 0 ] -then - # convert the remote protocol to https - REMOTE=$(echo $REMOTE | tr ':' '/' | sed -e "s#git@#https://#") -fi -# -L follow redirect, -s silent, -# --max-time overall operation timeout, -I only download headers -whence curl > /dev/null && curl -L -s --max-time 3 -I ${REMOTE} > /dev/null || return 0 - if mkdir "$ZSH/log/update.lock" 2>/dev/null; then if [ -f ~/.zsh-update ]; then . ~/.zsh-update