GNU bug report logs - #28105
Inconsistent exit code with --files-without-match

Previous Next

Package: grep;

Reported by: Anthony Sottile <asottile <at> umich.edu>

Date: Tue, 15 Aug 2017 22:24: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: Paul Eggert <eggert <at> cs.ucla.edu>
To: Antonio Diaz Diaz <antonio <at> gnu.org>
Cc: 28105-done <at> debbugs.gnu.org
Subject: bug#28105: Inconsistent exit code with --files-without-match
Date: Sat, 22 Aug 2020 14:11:47 -0700
[Message part 1 (text/plain, inline)]
On 8/7/20 4:14 AM, Antonio Diaz Diaz wrote:
> I propose to revert this change to remain consistent with POSIX.

It's not a POSIX issue, since POSIX doesn't specify -L, which means grep can do 
whatever it wants if you specify -L.

> But in GNU grep 3.2 to 3.4 -q inverts the exit status when -L is also used. Now 'grep -L > /dev/null' and 'grep -Lq' return opposite values.

That is indeed a bug.

I looked into this a bit further, and it turns out that when the Git folks were 
told that git-grep behaved differently from GNU grep 3.1 and earlier, they 
changed git-grep to match. This was around the same time we changed GNU grep to 
behave more like the git-grep at the time. What a comedy of errors, huh?

Anyway, given all these issues it does seem like it's wise to revert the change. 
I installed the attached patch into GNU grep master, with the goal of something 
like this appearing in the next grep release. Thanks for reporting the problem.
[0001-Revert-L-exit-status-change-introduced-in-grep-3.2.patch (text/x-patch, attachment)]

This bug report was last modified 4 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.