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