summaryrefslogtreecommitdiffstats
path: root/tests/util.sh
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2023-10-19 17:05:36 -0400
committerTavian Barnes <tavianator@tavianator.com>2023-10-19 17:05:36 -0400
commit13053c43ee8f5a2a5f7a66258d047e1b68203da3 (patch)
tree897b35cbe65f284b65d0874b3bf2f6037a26360d /tests/util.sh
parent785a3f2d777627f39bed44f4ae7a0180d5184109 (diff)
downloadbfs-13053c43ee8f5a2a5f7a66258d047e1b68203da3.tar.xz
tests: Don't unset array[-1]
This was only added in Bash 4.3 which is too new for macOS.
Diffstat (limited to 'tests/util.sh')
-rw-r--r--tests/util.sh13
1 files changed, 7 insertions, 6 deletions
diff --git a/tests/util.sh b/tests/util.sh
index 5131522..efc24b0 100644
--- a/tests/util.sh
+++ b/tests/util.sh
@@ -160,12 +160,13 @@ defer() {
# Pop a single command from the defer stack and run it
pop_defer() {
- local cmd="${DEFER_CMDS[-1]}"
- local file="${DEFER_FILES[-1]}"
- local line="${DEFER_LINES[-1]}"
- unset "DEFER_CMDS[-1]"
- unset "DEFER_FILES[-1]"
- unset "DEFER_LINES[-1]"
+ local i=$((${#DEFER_CMDS[@]} - 1))
+ local cmd="${DEFER_CMDS[$i]}"
+ local file="${DEFER_FILES[$i]}"
+ local line="${DEFER_LINES[$i]}"
+ unset "DEFER_CMDS[$i]"
+ unset "DEFER_FILES[$i]"
+ unset "DEFER_LINES[$i]"
local ret=0
eval "$cmd" || ret=$?