diff options
author | Martin Schulze <martin.schulze@vireso.de> | 2023-08-26 01:17:03 +0300 |
---|---|---|
committer | Martin Schulze <martin.schulze@vireso.de> | 2023-08-26 01:17:03 +0300 |
commit | 2315212fbae9f1c380db26c17e169f51a6a489a1 (patch) | |
tree | f798570410572a5039499755f76e2c6d5acb6ddc | |
parent | 6af41847af3cb820d7e8a4a02cdced726d5e7b55 (diff) |
Reuse BATS_SAVED_PATH
-rw-r--r-- | load.bash | 5 | ||||
-rw-r--r-- | src/output.bash | 4 |
2 files changed, 6 insertions, 3 deletions
@@ -1,7 +1,10 @@ # Preserve path at the time this file was sourced # This prevents using of user-defined mocks/stubs that modify the PATH -_BATSLIB_PATH="$PATH" +# BATS_SAVED_PATH was introduced in bats-core v1.10.0 +# if it is already set, we can use its more robust value +# else we try to recreate it here +BATS_SAVED_PATH="${BATS_SAVED_PATH-$PATH}" source "$(dirname "${BASH_SOURCE[0]}")/src/output.bash" source "$(dirname "${BASH_SOURCE[0]}")/src/error.bash" diff --git a/src/output.bash b/src/output.bash index 6d260b1..bb3ff4a 100644 --- a/src/output.bash +++ b/src/output.bash @@ -38,7 +38,7 @@ batslib_err() { { if (( $# > 0 )); then echo "$@" else - ( PATH="$_BATSLIB_PATH"; command cat -; ) + ( PATH="$BATS_SAVED_PATH"; command cat -; ) fi } >&2 } @@ -273,7 +273,7 @@ batslib_mark() { batslib_decorate() { echo echo "-- $1 --" - ( PATH="$_BATSLIB_PATH"; command cat -; ) + ( PATH="$BATS_SAVED_PATH"; command cat -; ) echo '--' echo } |