diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2023-10-19 17:05:36 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2023-10-19 17:05:36 -0400 |
commit | 13053c43ee8f5a2a5f7a66258d047e1b68203da3 (patch) | |
tree | 897b35cbe65f284b65d0874b3bf2f6037a26360d | |
parent | 785a3f2d777627f39bed44f4ae7a0180d5184109 (diff) | |
download | bfs-13053c43ee8f5a2a5f7a66258d047e1b68203da3.tar.xz |
tests: Don't unset array[-1]
This was only added in Bash 4.3 which is too new for macOS.
-rw-r--r-- | tests/util.sh | 13 |
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=$? |