Grep: Add DragonFly README files
[dragonfly.git] / gnu / usr.bin / grep / tests / status.sh
1 #! /bin/sh
2 # Test for status code for GNU grep.
3 # status code
4 #  0 match found
5 #  1 no match
6 #  2 file not found
7
8 : ${srcdir=.}
9
10 failures=0
11
12 # should return 0 found a match
13 echo "abcd" | ${GREP} -E -e 'abc' > /dev/null 2>&1
14 if test $? -ne 0 ; then
15         echo "Status: Wrong status code, test \#1 failed"
16         failures=1
17 fi
18
19 # should return 1 found no match
20 echo "abcd" | ${GREP} -E -e 'zbc' > /dev/null 2>&1
21 if test $? -ne 1 ; then
22         echo "Status: Wrong status code, test \#2 failed"
23         failures=1
24 fi
25
26 # the filename MMMMMMMM.MMM should not exist hopefully
27 # should return 2 file not found
28 if test -b MMMMMMMM.MMM; then
29         echo "Please remove MMMMMMMM.MMM to run check"
30 else
31         ${GREP} -E -e 'abc' MMMMMMMM.MMM> /dev/null 2>&1
32         if test $? -ne 2 ; then
33                 echo "Status: Wrong status code, test \#3 failed"
34                 failures=1
35         fi
36 fi
37
38 exit $failures