diff options
author | Zev Weiss <zev@bewilderbeest.net> | 2016-06-03 21:49:44 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2016-06-03 21:58:44 -0700 |
commit | c269bec26e884cfe2d47293cd5fdfc6dc8f70923 (patch) | |
tree | 489e85dd6c57fc859b5430c58259b5f9ece8e01a | |
parent | 3ddf995f9c9651d8ca8a6d23655e956cb807fb36 (diff) | |
download | grep-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-x | tests/status | 3 |
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 |