source: trunk/essentials/sys-apps/grep/tests/file.sh

Last change on this file was 2557, checked in by bird, 19 years ago

grep 2.5.1a

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