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


View this message in rfc822 format

From: Dennis Clarke <dclarke <at> blastwave.org>
To: 78891 <at> debbugs.gnu.org
Subject: bug#78891: Option to make grep always exit with 0
Date: Wed, 25 Jun 2025 13:51:15 -0400
On 6/25/25 13:14, Paul Eggert wrote:
> 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.
> 
> 

I am at great risk of falling into a bike shed[1] here. If grep
works fine and all is happy then we get a zero return value. All
other possible situations *should* return a non-zero error status
that helps silly old UNIX people like me.

If someone needs to write if-then-else-what? clause stuff in code
then that is correct behavior. Why fix that which works fine?

-- 
--
Dennis Clarke
RISC-V/SPARC/PPC/ARM/CISC
UNIX and Linux spoken

[1] https://en.wikipedia.org/wiki/Law_of_triviality




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.