From e527c1b288e15eadead25e01c29b5e8b074601a7 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Thu, 19 Oct 2023 09:34:58 -0400 Subject: tests: Fix uses of $? with set -e --- tests/tests.sh | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/tests/tests.sh b/tests/tests.sh index b159ea2..83f5b68 100755 --- a/tests/tests.sh +++ b/tests/tests.sh @@ -507,14 +507,15 @@ function bfs_verbose() { function invoke_bfs() { bfs_verbose "$@" - "${BFS[@]}" "$@" - local status="$?" + + local ret=0 + "${BFS[@]}" "$@" || ret=$? # Allow bfs to fail, but not crash - if ((status > 125)); then - exit "$status" + if ((ret > 125)); then + exit "$ret" else - return "$status" + return "$ret" fi } @@ -528,13 +529,14 @@ function bfs_pty() { test -n "${UNBUFFER:-}" || skip bfs_verbose "$@" - "$UNBUFFER" bash -c 'stty cols 80 rows 24 && "$@"' bash "${BFS[@]}" "$@" - local status="$?" - if ((status > 125)); then - exit "$status" + local ret=0 + "$UNBUFFER" bash -c 'stty cols 80 rows 24 && "$@"' bash "${BFS[@]}" "$@" || ret=$? + + if ((ret > 125)); then + exit "$ret" else - return "$status" + return "$ret" fi } -- cgit v1.2.3