Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/bats-core/bats-support.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Schulze <martin.schulze@vireso.de>2023-08-26 01:17:03 +0300
committerMartin Schulze <martin.schulze@vireso.de>2023-08-26 01:17:03 +0300
commit2315212fbae9f1c380db26c17e169f51a6a489a1 (patch)
treef798570410572a5039499755f76e2c6d5acb6ddc
parent6af41847af3cb820d7e8a4a02cdced726d5e7b55 (diff)
Reuse BATS_SAVED_PATH
-rw-r--r--load.bash5
-rw-r--r--src/output.bash4
2 files changed, 6 insertions, 3 deletions
diff --git a/load.bash b/load.bash
index 62c4622..3f52722 100644
--- a/load.bash
+++ b/load.bash
@@ -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
}