summaryrefslogtreecommitdiffstats
path: root/gnu/usr.bin/grep/tests/empty.sh
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/usr.bin/grep/tests/empty.sh')
-rwxr-xr-xgnu/usr.bin/grep/tests/empty.sh30
1 files changed, 30 insertions, 0 deletions
diff --git a/gnu/usr.bin/grep/tests/empty.sh b/gnu/usr.bin/grep/tests/empty.sh
new file mode 100755
index 0000000..8c75196
--- /dev/null
+++ b/gnu/usr.bin/grep/tests/empty.sh
@@ -0,0 +1,30 @@
+#! /bin/sh
+# test that the empty file means no pattern
+# and an empty pattern means match all.
+
+: ${srcdir=.}
+
+failures=0
+
+# should return 0 found a match
+echo "abcd" | ${GREP} -E -e '' > /dev/null 2>&1
+if test $? -ne 0 ; then
+ echo "Status: Wrong status code, test \#1 failed"
+ failures=1
+fi
+
+# should return 1 found no match
+echo "abcd" | ${GREP} -E -f /dev/null > /dev/null 2>&1
+if test $? -ne 1 ; then
+ echo "Status: Wrong status code, test \#2 failed"
+ failures=1
+fi
+
+# should return 0 found a match
+echo "abcd" | ${GREP} -E -f /dev/null -e "abc" > /dev/null 2>&1
+if test $? -ne 0 ; then
+ echo "Status: Wrong status code, test \#3 failed"
+ failures=1
+fi
+
+exit $failures
OpenPOWER on IntegriCloud