From 13053c43ee8f5a2a5f7a66258d047e1b68203da3 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Thu, 19 Oct 2023 17:05:36 -0400 Subject: tests: Don't unset array[-1] This was only added in Bash 4.3 which is too new for macOS. --- tests/util.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'tests/util.sh') 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=$? -- cgit v1.2.3