Skip to content

Commit 253ccec

Browse files
authored
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.)
1 parent 92d6530 commit 253ccec

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

env.sh

+14-3
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,22 @@
44
#
55
# See also: ./.envrc
66

7+
OLD_SHELL_OPTS=$-
78
set -o xtrace
8-
OMICRON_WS="$(readlink -f $(dirname "${BASH_SOURCE[0]}"))"
9+
10+
OMICRON_WS=$(readlink -f "$(dirname "${BASH_SOURCE[0]}")")
911
export PATH="$OMICRON_WS/out/cockroachdb/bin:$PATH"
1012
export PATH="$OMICRON_WS/out/clickhouse:$PATH"
1113
export PATH="$OMICRON_WS/out/dendrite-stub/bin:$PATH"
1214
export PATH="$OMICRON_WS/out/mgd/root/opt/oxide/mgd/bin:$PATH"
13-
unset OMICRON_WS
14-
set +o xtrace
15+
16+
# if xtrace was set previously, do not unset it
17+
case $OLD_SHELL_OPTS in
18+
*x*)
19+
unset OLD_SHELL_OPTS OMICRON_WS
20+
;;
21+
*)
22+
unset OLD_SHELL_OPTS OMICRON_WS
23+
set +o xtrace
24+
;;
25+
esac

0 commit comments

Comments
 (0)