diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2016-04-22 04:38:07 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2016-04-22 04:38:07 +0000 |
commit | 28ef1abc10cfbc2c3d2747c008eb2300858d0426 (patch) | |
tree | 41208fb8f393e6cb6cc8f939623ad47a0db17876 /tests/grep-dir | |
download | grep-tarball-28ef1abc10cfbc2c3d2747c008eb2300858d0426.tar.gz |
Diffstat (limited to 'tests/grep-dir')
-rwxr-xr-x | tests/grep-dir | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/grep-dir b/tests/grep-dir new file mode 100755 index 0000000..de14d62 --- /dev/null +++ b/tests/grep-dir @@ -0,0 +1,25 @@ +#!/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 >/dev/null 2>&1; then + l=1 u=1 L=0 U=1 +else + l=2 u=127 L=2 U=127 +fi + +echo x | grep -f a/; { test $? -ge $L && test $? -le $U; } || fail=1 +echo x | grep -if a/; { test $? -ge $L && test $? -le $U; } || fail=1 +echo x | grep -Ff a/; { test $? -ge $L && test $? -le $U; } || fail=1 +echo x | grep -Fif a/; { test $? -ge $L && test $? -le $U; } || fail=1 + +grep -f a/ < /dev/null; { test $? -ge $l && test $? -le $u; } || fail=1 +grep -if a/ < /dev/null; { test $? -ge $l && test $? -le $u; } || fail=1 +grep -Ff a/ < /dev/null; { test $? -ge $l && test $? -le $u; } || fail=1 +grep -Fif a/ < /dev/null; { test $? -ge $l && test $? -le $u; } || fail=1 + +Exit $fail |