summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorMarc Cornellà <marc@mcornella.com>2024-04-18 07:16:42 +0200
committerMarc Cornellà <marc@mcornella.com>2024-04-18 07:16:42 +0200
commitc262ffbb68e6dfc30b619e6ce6bdbd00f27b8a71 (patch)
tree7449765bd3eafabc7d86cd349db2400ecc07e7f5 /tools
parenteafa78217d836115a99f80bddfcd0a8901a15f77 (diff)
downloadzsh-c262ffbb68e6dfc30b619e6ce6bdbd00f27b8a71.tar.gz
zsh-c262ffbb68e6dfc30b619e6ce6bdbd00f27b8a71.tar.bz2
zsh-c262ffbb68e6dfc30b619e6ce6bdbd00f27b8a71.zip
fix(update): define `$ZSH` if undefined (#12273)
Fixes #12273 Fixes https://github.com/topgrade-rs/topgrade/issues/519
Diffstat (limited to 'tools')
-rwxr-xr-xtools/upgrade.sh7
1 files changed, 6 insertions, 1 deletions
diff --git a/tools/upgrade.sh b/tools/upgrade.sh
index d7016aa44..5eb90ab41 100755
--- a/tools/upgrade.sh
+++ b/tools/upgrade.sh
@@ -10,9 +10,14 @@ fi
# Protect against unwanted sourcing
case "$ZSH_EVAL_CONTEXT" in
- *:file) echo "error: this file should not be sourced" && return ;;
+ *:file) echo "error: this file should not be sourced" && return 1 ;;
esac
+# Define "$ZSH" if not defined -- in theory this should be `export`ed by the calling script
+if [[ -z "$ZSH" ]]; then
+ ZSH="${0:a:h:h}"
+fi
+
cd "$ZSH"
verbose_mode="default"