]> Sergey Matveev's repositories - bfs.git/commitdiff
tests: Fix uses of $? with set -e
authorTavian Barnes <tavianator@tavianator.com>
Thu, 19 Oct 2023 13:34:58 +0000 (09:34 -0400)
committerTavian Barnes <tavianator@tavianator.com>
Thu, 19 Oct 2023 13:34:58 +0000 (09:34 -0400)
tests/tests.sh

index b159ea2dc8f5fd9bd80ec21f8e6e798a9cdbda8b..83f5b68e21a7cbcbcd6c22fa7fb14b9906c6d1b1 100755 (executable)
@@ -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
 }