Thanks for catching that. I installed your patch, along with the attached patch which fixes a similar test-case bug elsewhere (present since 2010!).
>From 68d3c0672cc47939625e1cb7edbd4e2823312056 Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Fri, 3 Jun 2016 21:57:52 -0700
Subject: [PATCH] tests: fix similar bug in exit status test

* tests/grep-dir (status_range): New shell function.
Use it to fix bug where $? was not saved properly.
---
 tests/grep-dir | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/tests/grep-dir b/tests/grep-dir
index de14d62..7f8d6ca 100755
--- a/tests/grep-dir
+++ b/tests/grep-dir
@@ -12,14 +12,20 @@ else
   l=2 u=127 L=2 U=127
 fi
 
-echo x | grep -f a/; { test $? -ge $L && test $? -le $U; } || fail=1
-echo x | grep -if a/; { test $? -ge $L && test $? -le $U; } || fail=1
-echo x | grep -Ff a/; { test $? -ge $L && test $? -le $U; } || fail=1
-echo x | grep -Fif a/; { test $? -ge $L && test $? -le $U; } || fail=1
+status_range ()
+{
+  status=$?
+  { test $1 -le $status && test $status -le $2; } || fail=1
+}
 
-grep -f a/ < /dev/null; { test $? -ge $l && test $? -le $u; } || fail=1
-grep -if a/ < /dev/null; { test $? -ge $l && test $? -le $u; } || fail=1
-grep -Ff a/ < /dev/null; { test $? -ge $l && test $? -le $u; } || fail=1
-grep -Fif a/ < /dev/null; { test $? -ge $l && test $? -le $u; } || fail=1
+echo x | grep -f a/; status_range $L $U
+echo x | grep -if a/; status_range $L $U
+echo x | grep -Ff a/; status_range $L $U
+echo x | grep -Fif a/; status_range $L $U
+
+grep -f a/ < /dev/null; status_range $l $u
+grep -if a/ < /dev/null; status_range $l $u
+grep -Ff a/ < /dev/null; status_range $l $u
+grep -Fif a/ < /dev/null; status_range $l $u
 
 Exit $fail
-- 
2.7.4

Reply via email to