summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAlain Magloire <alainm@rcsm.ee.mcgill.ca>2001-02-08 16:12:10 +0000
committerAlain Magloire <alainm@rcsm.ee.mcgill.ca>2001-02-08 16:12:10 +0000
commit66db7a353fdcc432905f1e8bc97a6a4cf8d06dff (patch)
treecdffa2aff0bacbd8b7d2357332c2f25c92aa9016 /tests
parentafa053f2f7b95a2ba3d866e9dc4da40541ed3f6f (diff)
downloadgrep-66db7a353fdcc432905f1e8bc97a6a4cf8d06dff.tar.gz
Exit status fix.
POSIX.2 conformance fixes: grep -q now exits with status zero if an input line is selected, even if an error also occurs. grep -s no longer affects exit status. * src/grep.c (suppress_errors): Move definition earlier so that suppressible_error can use it. (suppressible_error): New function. (exit_on_match): New var. (grepbuf): If exit_on_match is nonzero, exit with status zero immediately. (grep, grepfile, grepdir): Invoke suppressible_error. (main): -q sets exit_on_match. * doc/grep.1, doc/grep.texi, NEWS: Document -q's behavior as required by POSIX.2. * tests/status.sh: Test for -q and -s behavior as conforming to POSIX.2.
Diffstat (limited to 'tests')
-rw-r--r--tests/status.sh18
1 files changed, 16 insertions, 2 deletions
diff --git a/tests/status.sh b/tests/status.sh
index 8dac66b3..4f08b8a3 100644
--- a/tests/status.sh
+++ b/tests/status.sh
@@ -24,15 +24,29 @@ if test $? -ne 1 ; then
fi
# the filename MMMMMMMM.MMM should not exist hopefully
-# should return 2 file not found
if test -r MMMMMMMM.MMM; then
echo "Please remove MMMMMMMM.MMM to run check"
else
- ${GREP} -E -e 'abc' MMMMMMMM.MMM> /dev/null 2>&1
+ # should return 2 file not found
+ ${GREP} -E -e 'abc' MMMMMMMM.MMM > /dev/null 2>&1
if test $? -ne 2 ; then
echo "Status: Wrong status code, test \#3 failed"
failures=1
fi
+
+ # should return 2 file not found
+ ${GREP} -E -s -e 'abc' MMMMMMMM.MMM > /dev/null 2>&1
+ if test $? -ne 2 ; then
+ echo "Status: Wrong status code, test \#4 failed"
+ failures=1
+ fi
+
+ # should return 0 found a match
+ echo "abcd" | ${GREP} -E -q -s 'abc' MMMMMMMM.MMM - > /dev/null 2>&1
+ if test $? -ne 0 ; then
+ echo "Status: Wrong status code, test \#5 failed"
+ failures=1
+ fi
fi
exit $failures