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 #8 received at 78891 <at> debbugs.gnu.org (full text, mbox):

From: "Dale R. Worley" <Dale.Worley <at> comcast.net>
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: Tue, 24 Jun 2025 14:22:28 -0400
Thomas Güttler Mailinglisten <guettliml <at> gmail.com> writes:
> To make Bash more robust, I use the "strict mode".
>
> This works fine, except that very often I want to filter out some
> output, and it does not matter to me if there is a match or not.
>
> Afaik there is no option to make `grep` always exit with a zero exit
> status. No matter if a match was found or not. Errors like "file not found"
> should still return a non-zero exit status.

Well, this isn't what you asked for, but it's a reasonaby terse way to
get the effect without modifying grep:

    grep ... || [[ $? != 2 ]]

That has an exit status of 1 if grep exits with 2, and an exit status of
0 otherwise.

Dale




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.