Line | |
---|
1 | #!/bin/sh
|
---|
2 | # Test for POSIX.2 options for grep
|
---|
3 | #
|
---|
4 | # grep -E -f pattern_file file
|
---|
5 | # grep -F -f pattern_file file
|
---|
6 | # grep -G -f pattern_file file
|
---|
7 | #
|
---|
8 |
|
---|
9 | : ${srcdir=.}
|
---|
10 |
|
---|
11 | failures=0
|
---|
12 |
|
---|
13 | cat <<EOF >patfile
|
---|
14 | radar
|
---|
15 | MILES
|
---|
16 | GNU
|
---|
17 | EOF
|
---|
18 |
|
---|
19 | # match
|
---|
20 | echo "miles" | ${GREP} -i -E -f patfile > /dev/null 2>&1
|
---|
21 | if test $? -ne 0 ; then
|
---|
22 | echo "File_pattern: Wrong status code, test \#1 failed"
|
---|
23 | failures=1
|
---|
24 | fi
|
---|
25 |
|
---|
26 | # match
|
---|
27 | echo "GNU" | ${GREP} -G -f patfile > /dev/null 2>&1
|
---|
28 | if test $? -ne 0 ; then
|
---|
29 | echo "File_pattern: Wrong status code, test \#2 failed"
|
---|
30 | failures=1
|
---|
31 | fi
|
---|
32 |
|
---|
33 | # checking for no match
|
---|
34 | echo "ridar" | ${GREP} -F -f patfile > /dev/null 2>&1
|
---|
35 | if test $? -ne 1 ; then
|
---|
36 | echo "File_pattern: Wrong status code, test \#3 failed"
|
---|
37 | failures=1
|
---|
38 | fi
|
---|
39 |
|
---|
40 | cat <<EOF >patfile
|
---|
41 |
|
---|
42 | EOF
|
---|
43 | # empty pattern : every match
|
---|
44 | echo "abbcd" | ${GREP} -F -f patfile > /dev/null 2>&1
|
---|
45 | if test $? -ne 0 ; then
|
---|
46 | echo "File_pattern: Wrong status code, test \#4 failed"
|
---|
47 | failures=1
|
---|
48 | fi
|
---|
49 |
|
---|
50 | cp /dev/null patfile
|
---|
51 |
|
---|
52 | # null pattern : no match
|
---|
53 | echo "abbcd" | ${GREP} -F -f patfile > /dev/null 2>&1
|
---|
54 | if test $? -ne 1 ; then
|
---|
55 | echo "File_pattern: Wrong status code, test \#5 failed"
|
---|
56 | failures=1
|
---|
57 | fi
|
---|
58 |
|
---|
59 | exit $failures
|
---|
Note:
See
TracBrowser
for help on using the repository browser.