Subject: bug#78891: Option to make grep always exit with 0

From: "Dale R. Worley" <[email-masked]>
Date: Tue, 24 Jun 2025 14:22:28 -0400

Thomas Güttler Mailinglisten <[email-masked]> 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