summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2012-04-17 13:37:10 +0200
committerJim Meyering <meyering@redhat.com>2012-04-17 17:26:55 +0200
commit55cf7b6a1905320c36702a476b09ebb29a2934d3 (patch)
treed7465af2d4e05fb91664123180b1ca0db00e6934 /src
parenta2e0193455e620f6bad1005500da418d9eba2ae6 (diff)
downloadgrep-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 'src')
-rw-r--r--src/main.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/main.c b/src/main.c
index 82cae33c..c5a84898 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1367,10 +1367,11 @@ grepdesc (int desc, int command_line)
suppressible_error (filename, errno);
return status;
}
- if ((directories == SKIP_DIRECTORIES && S_ISDIR (st.st_mode))
- || ((devices == SKIP_DEVICES
- || (devices == READ_COMMAND_LINE_DEVICES && !command_line))
- && is_device_mode (st.st_mode)))
+ if (desc != STDIN_FILENO
+ && ((directories == SKIP_DIRECTORIES && S_ISDIR (st.st_mode))
+ || ((devices == SKIP_DEVICES
+ || (devices == READ_COMMAND_LINE_DEVICES && !command_line))
+ && is_device_mode (st.st_mode))))
goto closeout;
/* If there is a regular file on stdout and the current file refers