summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZev Weiss <zev@bewilderbeest.net>2016-06-03 21:49:44 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2016-06-03 21:58:44 -0700
commitc269bec26e884cfe2d47293cd5fdfc6dc8f70923 (patch)
tree489e85dd6c57fc859b5430c58259b5f9ece8e01a
parent3ddf995f9c9651d8ca8a6d23655e956cb807fb36 (diff)
downloadgrep-c269bec26e884cfe2d47293cd5fdfc6dc8f70923.tar.gz
tests: fix bug in exit status test
When checking $? against multiple values, save its value in another variable and check that so as to avoid tests beyond the first seeing a $? clobbered by earlier ones. * tests/status: save $? in a temporary variable before testing it.
-rwxr-xr-xtests/status3
1 files changed, 2 insertions, 1 deletions
diff --git a/tests/status b/tests/status
index 2a2d6e04..37703be5 100755
--- a/tests/status
+++ b/tests/status
@@ -49,7 +49,8 @@ else
# should return 0 (found a match) or 2 (file not found)
echo "abcd" | grep -E -s 'abc' - MMMMMMMM.MMM > /dev/null 2>&1
- if test $? -ne 0 && test $? -ne 2 ; then
+ status=$?
+ if test $status -ne 0 && test $status -ne 2 ; then
echo "Status: Wrong status code, test \#5 failed"
fail=1
fi