From 253ccecc68b8516ab6a93cc05a59c558d0accb5e Mon Sep 17 00:00:00 2001 From: iliana etaoin Date: Fri, 21 Jun 2024 09:45:52 -0700 Subject: [PATCH] only unset xtrace if env.sh set it first (#5875) I noticed that the Buildomat logs for some of our tests didn't have execution tracing, despite `set -o xtrace` at the top of their scripts! Turns out env.sh was the cause. Despite this script being Bash-specific (`$BASH_SOURCE`) I went with a POSIXy implementation here. (Also fixed quoting, in case your checkout is within a directory path containing spaces.) --- env.sh | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/env.sh b/env.sh index 74f3d1caf4..6a84c35902 100644 --- a/env.sh +++ b/env.sh @@ -4,11 +4,22 @@ # # See also: ./.envrc +OLD_SHELL_OPTS=$- set -o xtrace -OMICRON_WS="$(readlink -f $(dirname "${BASH_SOURCE[0]}"))" + +OMICRON_WS=$(readlink -f "$(dirname "${BASH_SOURCE[0]}")") export PATH="$OMICRON_WS/out/cockroachdb/bin:$PATH" export PATH="$OMICRON_WS/out/clickhouse:$PATH" export PATH="$OMICRON_WS/out/dendrite-stub/bin:$PATH" export PATH="$OMICRON_WS/out/mgd/root/opt/oxide/mgd/bin:$PATH" -unset OMICRON_WS -set +o xtrace + +# if xtrace was set previously, do not unset it +case $OLD_SHELL_OPTS in + *x*) + unset OLD_SHELL_OPTS OMICRON_WS + ;; + *) + unset OLD_SHELL_OPTS OMICRON_WS + set +o xtrace + ;; +esac