GNU bug report logs - #78891
Option to make grep always exit with 0

Previous Next

Package: grep;

Reported by: Thomas Güttler Mailinglisten <guettliml <at> gmail.com>

Date: Tue, 24 Jun 2025 14:36:04 UTC

Severity: normal

Full log


Message #17 received at 78891 <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Thomas Güttler Mailinglisten <guettliml <at> gmail.com>
Cc: 78891 <at> debbugs.gnu.org
Subject: Re: bug#78891: Option to make grep always exit with 0
Date: Wed, 25 Jun 2025 10:14:52 -0700
On 2025-06-24 22:28, Thomas Güttler Mailinglisten wrote:
>   During the last months I wrote
> a lot of Bash code, and often I needed to handle the non-zero exit code of
> grep.
> 
> It would be handy to have an option to make grep always return zero (except
> "file not found" or similar errors).

I dunno, there are several commands like grep that return exit status 
1/2 for different kinds of "failure". ("diff", for example.) I doubt 
whether we want to add such an option to all these commands.

"grep GREPARGS || test $? = 1" is short and easy to remember and has 
worked everywhere for decades. If you dislike its syntax you can package 
it inside a shell function.




This bug report was last modified 50 days ago.

Previous Next


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