Skip to content

Commit

Permalink
only unset xtrace if env.sh set it first (#5875)
Browse files Browse the repository at this point in the history
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.)
  • Loading branch information
iliana authored Jun 21, 2024
1 parent 92d6530 commit 253ccec
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 253ccec

Please sign in to comment.