From c262ffbb68e6dfc30b619e6ce6bdbd00f27b8a71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Thu, 18 Apr 2024 07:16:42 +0200 Subject: [PATCH] fix(update): define `$ZSH` if undefined (#12273) Fixes #12273 Fixes https://github.com/topgrade-rs/topgrade/issues/519 --- tools/upgrade.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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"