GNU bug report logs -
#37716
grep exit status with -L redirected to /dev/null
Previous Next
Reported by: Adam Sampson <ats <at> offog.org>
Date: Sat, 12 Oct 2019 14:23:01 UTC
Severity: normal
Done: Paul Eggert <eggert <at> cs.ucla.edu>
Bug is archived. No further changes may be made.
Full log
Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):
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
pj <at> usa.net
This bug report was last modified 5 years and 279 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.