diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2020-08-22 14:06:26 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2020-08-22 14:07:48 -0700 |
commit | 0435ebca64fbafcd62008c991dd9377d8a792dfc (patch) | |
tree | 8ece76a8399975b418a94719c61e8edf5609d6bc /src/grep.c | |
parent | afc59ea2006a456401f1e674fbb2893236a5a6f0 (diff) | |
download | grep-0435ebca64fbafcd62008c991dd9377d8a792dfc.tar.gz |
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.
Diffstat (limited to 'src/grep.c')
-rw-r--r-- | src/grep.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -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) { |