|
From: | Paul Eggert |
Subject: | bug#24941: Early termination bug in grep 2.26 |
Date: | Tue, 15 Nov 2016 00:17:03 -0800 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 |
Jim Meyering wrote:
Paul, what do you think about making your heuristic apply only for non-pipes?
I'm a bit dubious, as grep exits early for other reasons, and did so before the patch in question. For example, here:
seq 10000000000 | grep -q .This is as of grep 2.19 (2014), due to a bug report where grep performed badly by not exiting early <https://bugs.gnu.org/17427>. Which suggests that we'll get bug reports in this area no matter what grep does....
Looking at other implementations, Solaris 11 grep is similar with -q. And FreeBSD-current grep exits early for this case:
seq 10000000000 | grep -f /dev/nullCome to think of it, perhaps GNU grep should do a similar optimization for -f /dev/null, if only to keep up with FreeBSD.
All the above being said, I am sympathetic to the bug report. Perhaps we can eliminate the optimization if there are no file arguments and only options in the set -EFivx are specified. Something like that anyway. The idea is to catch common cases in old (and really, broken) scripts, without hurting performance in general.
[Prev in Thread] | Current Thread | [Next in Thread] |