GNU bug report logs - #30105
Additional "grep" parameter to change the exit code from 1 to 0, even if grep doesn't find pattern

Previous Next

Package: grep;

Reported by: Vasyl Vavrychuk <vvavrychuk <at> gmail.com>

Date: Sun, 14 Jan 2018 05:57:02 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: Vasyl Vavrychuk <vvavrychuk <at> gmail.com>
To: 30105 <at> debbugs.gnu.org
Subject: bug#30105: Additional "grep" parameter to change the exit code from 1 to 0,  even if grep doesn't find pattern
Date: Sun, 14 Jan 2018 07:21:11 +0200
> > I want to suggest my idea about a additional "grep" parameter which
> > would change the exit code 1 to 0, even when "grep" doesn't find a
> > pattern. I.e. something similar to "-0".
>
> Thanks, but you can avoid triggering your trap
> by appending "|| :" to your grep command.
>
> E.g.,
>
>     grep not-found /dev/null || :
>
> Then, even when grep fails, the shell sees only the successful
> exit code from the ":" (always succeeding) built-in command.

It replaces exit status 2 with success too.
I would like to have an option to return success if nothing is found but
still return fail if error happens.




This bug report was last modified 7 years and 125 days ago.

Previous Next


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