Subject: bug#37716: grep exit status with -L redirected to /dev/null

From: "Paul Jackson" <[email-masked]>
Date: Sat, 12 Oct 2019 17:29:57 -0500

This also happens when doing "grep -L" for something
that -is- in the file, redirected to /dev/null:

======

$ echo hello > thing
$ grep -L hello thing; echo $?
1
$ grep -L hello thing > /dev/null; echo $?
0

=======

My first guess, after a minute glancing at the code, and after
using strace to notice  that grep doesn't even try to invoke
a "write(2)" system call in these examples, if it notices that
its output is redirected to /dev/null, is that the exit status
of the grep command depends sometimes, somehow,  on
whether or not it decided to write out any results at all.

My strace observations in the previous paragraph are probably
reliable.  My guess as to the logic grep is using to determine
it's process exit status are probably not reliable.

-- 
                Paul Jackson
                [email-masked]