File: empty.sh

package info (click to toggle)
grep 2.2-1
  • links: PTS
  • area: main
  • in suites: slink
  • size: 1,376 kB
  • ctags: 1,634
  • sloc: ansic: 11,842; sh: 774; makefile: 233; sed: 148; awk: 9
file content (30 lines) | stat: -rwxr-xr-x 718 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#! /bin/sh
# test that the empty file means no pattern
# and an empty pattern means match all.

: ${srcdir=.}

failures=0

# should return 0 found a match
echo "abcd" | ${GREP} -E -e '' > /dev/null 2>&1
if test $? -ne 0 ; then
        echo "Status: Wrong status code, test \#1 failed"
        failures=1
fi

# should return 1 found no match
echo "abcd" | ${GREP} -E -f /dev/null  > /dev/null 2>&1
if test $? -ne 1 ; then
        echo "Status: Wrong status code, test \#2 failed"
        failures=1
fi

# should return 0 found a match
echo "abcd" | ${GREP} -E -f /dev/null -e "abc" > /dev/null 2>&1
if test $? -ne 0 ; then
        echo "Status: Wrong status code, test \#3 failed"
        failures=1
fi

exit $failures