]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - gnu/usr.bin/grep/tests/backref.sh
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / gnu / usr.bin / grep / tests / backref.sh
1 #!/bin/sh
2 # Test that backrefs are local to regex.
3 #
4 #
5
6 : ${srcdir=.}
7
8 failures=0
9
10 # checking for a palindrome
11 echo "radar" | ${GREP} -e '\(.\)\(.\).\2\1' > /dev/null 2>&1
12 if test $? -ne 0 ; then
13         echo "backref: palindrome, test \#1 failed"
14         failures=1
15 fi
16
17 # hit hard with the `Bond' tests
18 echo "civic" | ${GREP} -E -e '^(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?).?\9\8\7\6\5\4\3\2\1$' > /dev/null 2>&1
19 if test $? -ne 0 ; then
20         echo "Options: Bond, test \#2 failed"
21         failures=1
22 fi
23
24 # backref are local should be error
25 echo "123" | ${GREP} -e 'a\(.\)' -e 'b\1' > /dev/null 2>&1
26 if test $? -ne 2 ; then
27         echo "Options: Backref not local, test \#3 failed"
28         failures=1
29 fi
30
31 # Pattern should faile
32 echo "123" | ${GREP} -e '[' -e ']' > /dev/null 2>&1
33 if test $? -ne 2 ; then
34         echo "Options: Compiled not local, test \#3 failed"
35         failures=1
36 fi
37
38 exit $failures