From 0435ebca64fbafcd62008c991dd9377d8a792dfc Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 22 Aug 2020 14:06:26 -0700 Subject: Revert -L exit status change introduced in grep 3.2 Problems reported by Antonio Diaz Diaz in: https://bugs.gnu.org/28105#29 * NEWS, doc/grep.texi (Exit Status), src/grep.c (usage): Adjust documentation accordingly. * src/grep.c (grepdesc, main): Go back to old behavior. * tests/skip-read: Adjust tests accordingly. --- src/grep.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/grep.c') diff --git a/src/grep.c b/src/grep.c index 7ba602d9..5764b2a9 100644 --- a/src/grep.c +++ b/src/grep.c @@ -1864,11 +1864,11 @@ grepdesc (int desc, bool command_line) fflush_errno (); } - status = !count == !(list_files == LISTFILES_NONMATCHING); + status = !count; - if (list_files == LISTFILES_NONE || dev_null_output) + if (list_files == LISTFILES_NONE) finalize_input (desc, &st, ineof); - else if (status == 0) + else if (list_files == (status ? LISTFILES_NONMATCHING : LISTFILES_MATCHING)) { print_filename (); putchar_errno ('\n' & filename_mask); @@ -1997,7 +1997,7 @@ Context control:\n\ printf (_("\ When FILE is '-', read standard input. With no FILE, read '.' if\n\ recursive, '-' otherwise. With fewer than two FILEs, assume -h.\n\ -Exit status is 0 if any line (or file if -L) is selected, 1 otherwise;\n\ +Exit status is 0 if any line is selected, 1 otherwise;\n\ if any error occurs and -q is not given, the exit status is 2.\n")); emit_bug_reporting_address (); } @@ -2835,7 +2835,7 @@ main (int argc, char **argv) /* POSIX says -c, -l and -q are mutually exclusive. In this implementation, -q overrides -l and -L, which in turn override -c. */ - if (exit_on_match) + if (exit_on_match | dev_null_output) list_files = LISTFILES_NONE; if ((exit_on_match | dev_null_output) || list_files != LISTFILES_NONE) { -- cgit v1.2.1