GNU bug report logs - #37716
grep exit status with -L redirected to /dev/null

Previous Next

Package: grep;

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


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#37716: closed (grep exit status with -L redirected to /dev/null)
Date: Sun, 13 Oct 2019 01:34:02 +0000
[Message part 1 (text/plain, inline)]
Your message dated Sat, 12 Oct 2019 18:33:23 -0700
with message-id <2eec8445-b28d-7fa7-9fcd-06a5185416f8 <at> cs.ucla.edu>
and subject line Re: bug#37716: grep exit status with -L redirected to /dev/null
has caused the debbugs.gnu.org bug report #37716,
regarding grep exit status with -L redirected to /dev/null
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
37716: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=37716
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Adam Sampson <ats <at> offog.org>
To: bug-grep <at> gnu.org
Subject: grep exit status with -L redirected to /dev/null
Date: Sat, 12 Oct 2019 15:22:05 +0100
Hi grep maintainers,

This behaviour, with grep 3.3 built from source, is a bit surprising:

$ echo hello >thing
$ grep -L goodbye thing && echo OK
thing
OK
$ grep -L goodbye thing >/dev/null && echo OK
$

That is, when using -L, redirecting stdout to /dev/null has the same
effect on the exit code as specifying -q (the behaviour with -q is
described in the "Exit Status" section of the manual). This is a bit
awkward if you're using grep in a script, because you don't necessarily
have any control over whether stdout is /dev/null or not.

Cheers,

-- 
Adam Sampson <ats <at> offog.org>                         <http://offog.org/>


[Message part 3 (message/rfc822, inline)]
From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Adam Sampson <ats <at> offog.org>
Cc: Paul Jackson <pj <at> usa.net>, 37716-done <at> debbugs.gnu.org
Subject: Re: bug#37716: grep exit status with -L redirected to /dev/null
Date: Sat, 12 Oct 2019 18:33:23 -0700
[Message part 4 (text/plain, inline)]
Thanks for reporting that bug. To fix it, I installed the attached patch into 
grep master on Savannah.
[0001-grep-fix-grep-L-.-dev-null-bug.patch (text/x-patch, attachment)]

This bug report was last modified 5 years and 278 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.