fix(update): define `$ZSH` if undefined (#12273)
Fixes #12273
Fixes https://github.com/topgrade-rs/topgrade/issues/519
Diff
1diff --git a/tools/upgrade.sh b/tools/upgrade.sh
2index d7016aa449ccf1fe06bcc70306cda3879d1f7c92..5eb90ab41579a99942948a7041091d601ff9b89f 100755
3--- a/tools/upgrade.sh
4+++ b/tools/upgrade.sh
5@@ -10,9 +10,14 @@ fi
6 7 # Protect against unwanted sourcing
8 case "$ZSH_EVAL_CONTEXT" in
9- *:file) echo "error: this file should not be sourced" && return ;;
10+ *:file) echo "error: this file should not be sourced" && return 1 ;;
11 esac
1213+# Define "$ZSH" if not defined -- in theory this should be `export`ed by the calling script
14+if [[ -z "$ZSH" ]]; then
15+ ZSH="${0:a:h:h}"
16+fi
17+
18 cd "$ZSH"
1920 verbose_mode="default"