summaryrefslogtreecommitdiffstats
path: root/src/grep/tests/grep-dir
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-11 08:21:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-11 08:21:29 +0000
commit29cd838eab01ed7110f3ccb2e8c6a35c8a31dbcc (patch)
tree63ef546b10a81d461e5cf5ed9e98a68cd7dee1aa /src/grep/tests/grep-dir
parentInitial commit. (diff)
downloadkbuild-29cd838eab01ed7110f3ccb2e8c6a35c8a31dbcc.tar.xz
kbuild-29cd838eab01ed7110f3ccb2e8c6a35c8a31dbcc.zip
Adding upstream version 1:0.1.9998svn3589+dfsg.upstream/1%0.1.9998svn3589+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/grep/tests/grep-dir')
-rwxr-xr-xsrc/grep/tests/grep-dir31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/grep/tests/grep-dir b/src/grep/tests/grep-dir
new file mode 100755
index 0000000..4947512
--- /dev/null
+++ b/src/grep/tests/grep-dir
@@ -0,0 +1,31 @@
+#!/bin/sh
+# Case-insensitive grep with a 0-size input file would fail in grep up to 2.6.3
+. "${srcdir=.}/init.sh"; path_prepend_ ../src
+
+mkdir a || framework_failure
+
+# Lower and upper bound of valid exit status for "grep -f DIR",
+# when reading from empty and nonempty files, respectively.
+if cat a >acopy 2>&1 && cmp a acopy; then
+ l=1 u=1 L=0 U=1
+else
+ l=2 u=127 L=2 U=127
+fi
+
+status_range ()
+{
+ status=$?
+ { test $1 -le $status && test $status -le $2; } || fail=1
+}
+
+echo x | grep -f a/; status_range $L $U
+echo x | grep -if a/; status_range $L $U
+echo x | grep -Ff a/; status_range $L $U
+echo x | grep -Fif a/; status_range $L $U
+
+grep -f a/ < /dev/null; status_range $l $u
+grep -if a/ < /dev/null; status_range $l $u
+grep -Ff a/ < /dev/null; status_range $l $u
+grep -Fif a/ < /dev/null; status_range $l $u
+
+Exit $fail