summaryrefslogtreecommitdiffstats
path: root/src/grep/tests/empty-line
diff options
context:
space:
mode:
Diffstat (limited to 'src/grep/tests/empty-line')
-rwxr-xr-xsrc/grep/tests/empty-line41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/grep/tests/empty-line b/src/grep/tests/empty-line
new file mode 100755
index 0000000..25e9509
--- /dev/null
+++ b/src/grep/tests/empty-line
@@ -0,0 +1,41 @@
+#! /bin/sh
+# Test that the empty pattern matches everything.
+# Some of these tests failed in grep 2.18.
+
+. "${srcdir=.}/init.sh"; path_prepend_ ../src
+
+fail=0
+printf 'abc\n' >in || framework_failure_
+nl='
+'
+
+for opt in '' -E -F; do
+ case $opt in
+ '') prefix='\(\)\1';;
+ -E) prefix='()\1';;
+ -F) prefix="foo$nl";;
+ esac
+
+ for pattern in "" "$nl" "---$nl" "${nl}foo"; do
+ for pat in "$pattern" "$prefix$pattern"; do
+ grep $opt -e "$pat" in >out || fail=1
+ compare in out || fail=1
+
+ printf -- '%s\n' "$pat" >pat || framework_failure_
+ grep $opt -f pat in >out || fail=1
+ compare in out || fail=1
+
+ # Check that pattern files that end in non-newlines
+ # are treated as if a newline were appended.
+ case $pattern in
+ '' | *"$nl") ;;
+ *)
+ printf -- '%s' "$pat" >pat || framework_failure_
+ grep $opt -f pat in >out || fail=1
+ compare in out || fail=1;;
+ esac
+ done
+ done
+done
+
+Exit $fail