summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS2
-rw-r--r--src/grep.c5
-rwxr-xr-xtests/skip-read13
3 files changed, 16 insertions, 4 deletions
diff --git a/NEWS b/NEWS
index 06a186ac..29a0e8d2 100644
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,8 @@ GNU grep NEWS -*- outline -*-
more cautious about special patterns like (?-m) and (*FAIL).
[bug introduced in grep-2.23]
+ grep -m0 -L PAT FILE now outputs "FILE". [bug introduced in grep-2.5]
+
grep's use of getprogname no longer causes a build failure on HP-UX.
** Improvements
diff --git a/src/grep.c b/src/grep.c
index 066df8cb..a794af48 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -2818,8 +2818,9 @@ main (int argc, char **argv)
/* 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))
+ if ((max_count == 0
+ || (keycc == 0 && out_invert && !match_lines && !match_words))
+ && list_files != LISTFILES_NONMATCHING)
return EXIT_FAILURE;
if (color_option == 2)
diff --git a/tests/skip-read b/tests/skip-read
index 627d3626..1eef87e0 100755
--- a/tests/skip-read
+++ b/tests/skip-read
@@ -5,11 +5,20 @@
fail=0
+echo /dev/null >exp || framework_failure_
+
for opts in '-m0 y' '-f /dev/null' '-v ""'; do
for matcher in '' -E -F; do
- eval returns_ 1 grep $opts $matcher no-such-file > out || fail=1
- compare /dev/null out || fail=1
+ for file in /dev/null no-such-file; do
+ eval returns_ 1 grep $opts $matcher no-such-file > out || fail=1
+ compare /dev/null out || fail=1
+ eval returns_ 1 grep -l $opts $matcher /dev/null > out || fail=1
+ compare /dev/null out || fail=1
+ done
+ eval returns_ 1 grep -L $opts $matcher /dev/null > out || fail=1
+ compare exp out || fail=1
done
done
+
Exit $fail