summaryrefslogtreecommitdiff
path: root/gnu/usr.bin/grep/tests/backref.sh
diff options
context:
space:
mode:
authorTim J. Robbins <tjr@FreeBSD.org>2004-07-04 09:52:08 +0000
committerTim J. Robbins <tjr@FreeBSD.org>2004-07-04 09:52:08 +0000
commit6fdbbb54872ec7fac83387296f0165f7ad3400a9 (patch)
tree70ffe417c9436d51a3807610738f2a5993f7f0fc /gnu/usr.bin/grep/tests/backref.sh
parent7a39f4da90d53085484e72b7504a3e53dbc9f051 (diff)
Import GNU grep 2.5.1 (trimmed)vendor/misc-GNU/grep
Notes
svn path=/vendor/misc-GNU/dist1/; revision=131554
Diffstat (limited to 'gnu/usr.bin/grep/tests/backref.sh')
-rwxr-xr-xgnu/usr.bin/grep/tests/backref.sh38
1 files changed, 38 insertions, 0 deletions
diff --git a/gnu/usr.bin/grep/tests/backref.sh b/gnu/usr.bin/grep/tests/backref.sh
new file mode 100755
index 000000000000..83f6dcc9408a
--- /dev/null
+++ b/gnu/usr.bin/grep/tests/backref.sh
@@ -0,0 +1,38 @@
+#!/bin/sh
+# Test that backrefs are local to regex.
+#
+#
+
+: ${srcdir=.}
+
+failures=0
+
+# checking for a palindrome
+echo "radar" | ${GREP} -e '\(.\)\(.\).\2\1' > /dev/null 2>&1
+if test $? -ne 0 ; then
+ echo "backref: palindrome, test \#1 failed"
+ failures=1
+fi
+
+# hit hard with the `Bond' tests
+echo "civic" | ${GREP} -E -e '^(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?).?\9\8\7\6\5\4\3\2\1$' > /dev/null 2>&1
+if test $? -ne 0 ; then
+ echo "Options: Bond, test \#2 failed"
+ failures=1
+fi
+
+# backref are local should be error
+echo "123" | ${GREP} -e 'a\(.\)' -e 'b\1' > /dev/null 2>&1
+if test $? -ne 2 ; then
+ echo "Options: Backref not local, test \#3 failed"
+ failures=1
+fi
+
+# Pattern should faile
+echo "123" | ${GREP} -e '[' -e ']' > /dev/null 2>&1
+if test $? -ne 2 ; then
+ echo "Options: Compiled not local, test \#3 failed"
+ failures=1
+fi
+
+exit $failures