From eb793a669d731efc68c30c327b6b8498e1326f75 Mon Sep 17 00:00:00 2001 From: joe128 Date: Sun, 9 Jan 2022 16:18:15 +0100 Subject: [PATCH] fix infinite loop if error during pull by aborting autoupdate --- CHANGELOG.md | 4 ++++ anyScript.sh | 14 ++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b545824..9ff270d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## [3.1.1] - 2022-01-09 +### Fixed + - abort if there were an error during pull of new commits, to prevent an infinite loop + ## [3.1.0] - 2022-01-08 ### Added - show branch-tip after update diff --git a/anyScript.sh b/anyScript.sh index e129127..c41cd4c 100755 --- a/anyScript.sh +++ b/anyScript.sh @@ -34,13 +34,15 @@ if [ -n "${gitbin}" ] && [ ! -f "$(dirname "$0")/.autoUpdateDisable" ] && [ -z " echo "[autoUpdate] Found updates ($commits commits)..." [ $doHardReset -gt 0 ] && $gitbin reset --hard $gitbin pull --force - localTip=$(${gitbin} show --abbrev-commit --format=oneline $(${gitbin} rev-list --max-count=1 @{u}) | head -1) - echo "[autoUpdate] source is now at commit '$localTip'" + if [ ! $? ]; then + localTip=$(${gitbin} show --abbrev-commit --format=oneline $(${gitbin} rev-list --max-count=1 @{u}) | head -1) + echo "[autoUpdate] source is now at commit '$localTip'" - echo "[autoUpdate] Executing new version..." - exec "$(pwd -P)/${scriptName}" "$@" - # In case executing new fails - echo "[ERR][autoUpdate] Executing new version failed." + echo "[autoUpdate] Executing new version..." + exec "$(pwd -P)/${scriptName}" "$@" + fi + # In case there were an error (during pull or executing new) + echo "[ERR][autoUpdate] Pulling or executing new version failed." exit 1 fi echo "[autoUpdate] No updates available."