GNU bug report logs -
#41700
grep -v always exiting with 1 for empty file
Previous Next
Reported by: Andi Kleen <andi <at> firstfloor.org>
Date: Thu, 4 Jun 2020 04:33:01 UTC
Severity: normal
Tags: notabug
Done: Paul Eggert <eggert <at> cs.ucla.edu>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
If I am reading the grep.c code correctly,
asking grep to read a zero length file,
such as:
grep foo /dev/null
causes the code to quit, with a non-zero
exit status, fairly early on, as soon as the
first call to "fillbuf()" returns with 0 bytes read.
This seems to apply except in the case of
grep -L (list files not matching) which special
cases the exit status to enable listing an
empty file as non-matching.
Being a crusty old codger, I'd recommend
changing the grep(1) man page to match
the current behavior, as observed by Andi
and myself, rather than changing the code
to be consistent with what Andi, reasonably
enough, expected.
Every time any little detail like this changes,
somebody's code breaks quietly in the night.
However since I'm not volunteering to submit
the documentation (or code) patch, my vote
counts for little :).
Carry on.
--
Paul Jackson
pj <at> usa.net
This bug report was last modified 4 years and 239 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.