diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2016-11-17 21:05:42 -0800 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2016-11-19 01:18:31 -0800 |
commit | fc6fce9a16bc52aca11cd8f1ad2632943fe94201 (patch) | |
tree | a32ad60b845c616ea4756147f75adbf5958f1b68 /src | |
parent | 2a45b2fbe2ca6d2d6c161d1593511b92d9e4640e (diff) | |
download | grep-fc6fce9a16bc52aca11cd8f1ad2632943fe94201.tar.gz |
grep: treat -f /dev/null like -m0
* NEWS: Document this.
* src/grep.c (main): With -f /dev/null, don't bother to read the
input. This is what FreeBSD grep does.
* tests/Makefile.am (TESTS): Add skip-read.
* tests/skip-read: New file.
Diffstat (limited to 'src')
-rw-r--r-- | src/grep.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -2866,7 +2866,10 @@ main (int argc, char **argv) if (O_BINARY && !isatty (STDOUT_FILENO)) set_binary_mode (STDOUT_FILENO, O_BINARY); - if (max_count == 0) + /* If it is easy to see that matching cannot succeed (e.g., 'grep -f + /dev/null'), fail without reading the input. */ + if (max_count == 0 + || (keycc == 0 && out_invert && !match_lines && !match_words)) return EXIT_FAILURE; /* Prefer sysconf for page size, as getpagesize typically returns int. */ |