Greetings!
The attached patch add a `--pipe` option to grep. When used, grep
only exits with with nonzero status on error. In particular, it
doesn't signal "match" / "no match" through the exit code.
Here's an example using Bash:
# enable automatic error handling
set -eo pipefail
# grep fo
I noticed this one while doing:
$ grep sha[^s]e five-letter-words
share
which doesn't fit with:
$ grep sha.e five-letter-words
shade
shake
shale
shame
shape
share
shave
A reproducer is easy:
$ echo shame |grep sha[^s]e
(no output)
Almost any change to the regex & input will make it work, even
On Thu, Feb 17, 2022 at 7:46 AM Matthew Wilcox wrote:
> I noticed this one while doing:
>
> $ grep sha[^s]e five-letter-words
> share
>
> which doesn't fit with:
>
> $ grep sha.e five-letter-words
> shade
> shake
> shale
> shame
> shape
> share
> shave
>
> A reproducer is easy:
>
> $ echo shame |g
Never mind. bash glob-expanded 'sha[^s]e' to match 'share' which
was a directory in $HOME. Eventually, I'll learn to quote correctly.
On 2/16/22 23:57, Ulrich Eckhardt wrote:
In order to fix that bug in the above script, you currently have to
replace `grep ...` with `grep ... || [ $? = 1 ]`, which is not really
readable.
Actually, appending something "|| test $? -eq 1" looks readable to me;
plus, it already works and is port