Hello Tobias,

Tobias Geerinckx-Rice wrote:
Thank you for maintaining this package!

You are welcome! :-)


I.e. passing '-L' also 'flips' the return value.

Thank you for reporting this. It looks like a recent, backwards-incompatible change in GNU grep.

Both GNU grep 2.5 (2001) and 3.1 (2017) state that:
"Normally the exit status is 0 if a line is selected, 1 if no lines were
selected, and 2 if an error occurred."

But then, GNU grep 3.4 states[1]:
"Normally the exit status is 0 if a line is selected, 1 if no lines were selected, and 2 if an error occurred. However, if the -L or --files-without-match is used, the exit status is 0 if a file is listed, 1 if no files were listed, and 2 if an error occurred."

[1] http://www.gnu.org/software/grep/manual/html_node/Exit-Status.html


I can't find '-L's effect on exit status (if any) explicitly documented
anywhere, so I don't know who's correct.

Option '-L' is not in POSIX grep, but POSIX states that[2]:

EXIT STATUS
    The following exit values shall be returned:
     0  One or more lines were selected.
     1  No lines were selected.
    >1  An error occurred.

[2] http://pubs.opengroup.org/onlinepubs/9699919799/utilities/grep.html

Therefore the following change[3] in GNU grep 3.2 is not POSIX compliant:

"The --files-without-match (-L) option now causes grep to succeed when a file is listed, instead of when a line is selected. This resembles what git-grep does."

[3] http://git.savannah.gnu.org/cgit/grep.git/tree/NEWS#n62


The only "fix" I can think just now is to stop testing the exit status of grep when '-L' is specified. :-(


Best regards,
Antonio.

Reply via email to