bug-grep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Additional "grep" parameter to change the exit code from 1 to 0, even if


From: Robert
Subject: Additional "grep" parameter to change the exit code from 1 to 0, even if grep doesn't find pattern
Date: Fri, 02 Sep 2011 14:08:29 +0200

Hello everybody,

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".

Why?

In bash programming I often use the "trap" command with the "ERR"
parameter. "ERR" reacts when a normal command like "grep", "mount", etc.
produces an non-zero exit code. "ERR" is similar to the bash "set -e" or
"set -o errexit" option.

My thought is, that NOT finding a pattern, is not always a reason to
consider the result as an error or the command being unsuccessfully. In
my opinion, it would just be a handy way to avoid using "awk" or "sed",
which produce exit code 0, when NOT finding a pattern. 

Just an idea... :)

Kind regards,

Robert S.









reply via email to

[Prev in Thread] Current Thread [Next in Thread]