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