浏览代码

fix(update): define `$ZSH` if undefined (#12273)

Fixes #12273
Fixes https://github.com/topgrade-rs/topgrade/issues/519
Marc Cornellà 1 月之前
父节点
当前提交
c262ffbb68
共有 1 个文件被更改,包括 6 次插入1 次删除
  1. 6 1
      tools/upgrade.sh

+ 6 - 1
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"