Hello,
I noticed a subtle bug was recently introduced (by commit af6af288) in
grep's tests/status -- I believe the attached patch should fix it.
Thanks,
Zev
>From 198922006962729dc785b812c5243867a3083770 Mon Sep 17 00:00:00 2001
From: Zev Weiss <z...@bewilderbeest.net>
Date: Fri, 3 Jun 2016 01:28:11 -0500
Subject: [PATCH] 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.
---
tests/status | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tests/status b/tests/status
index 2a2d6e0..37703be 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
--
2.8.0.rc3