diff options
author | Jim Meyering <meyering@redhat.com> | 2012-04-17 13:37:10 +0200 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2012-04-17 17:26:55 +0200 |
commit | 55cf7b6a1905320c36702a476b09ebb29a2934d3 (patch) | |
tree | d7465af2d4e05fb91664123180b1ca0db00e6934 /tests | |
parent | a2e0193455e620f6bad1005500da418d9eba2ae6 (diff) | |
download | grep-55cf7b6a1905320c36702a476b09ebb29a2934d3.tar.gz |
grep: fix --devices=ACTION (-D) so stdin is once again exempt
An oversight in the 2.11 changes made it so "echo x|grep x" would
fail for those who set GREP_OPTIONS=--devices=skip.
* src/main.c (grepdesc): Ignore skip-related options when reading
from standard input.
* tests/skip-device: New file. Test for the above.
* tests/Makefile.am (TESTS): Add it.
* doc/grep.texi (File and Directory Selection): Clarify this point,
documenting the stdin exemption.
* NEWS (Bug fixes): Mention it, and add a few "[fixed in ...] notes.
Reported by Tino Keitel in http://bugs.debian.org/669084,
and forwarded to bug-grep by AnĂbal Monsalve Salazar.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile.am | 1 | ||||
-rwxr-xr-x | tests/skip-device | 14 |
2 files changed, 15 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index 13061fed..d0d622bd 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -78,6 +78,7 @@ TESTS = \ r-dot \ repetition-overflow \ reversed-range-endpoints \ + skip-device \ sjis-mb \ spencer1 \ spencer1-locale \ diff --git a/tests/skip-device b/tests/skip-device new file mode 100755 index 00000000..40645ea1 --- /dev/null +++ b/tests/skip-device @@ -0,0 +1,14 @@ +#!/bin/sh +# grep must ignore --devices=ACTION (-D) when reading stdin +# For grep-2.11, this test would fail. + +. "${srcdir=.}/init.sh"; path_prepend_ ../src + +# Test both with no file argument, and with "-". +echo foo | grep -D skip foo - || fail=1 +echo foo | grep --devices=skip foo || fail=1 + +# It's more insidious when the skip option is via the envvar: +echo foo | GREP_OPTIONS=--devices=skip grep foo || fail=1 + +Exit $fail |