On Fri, May 30, 2014 at 8:56 AM, Jim Meyering <[email protected]> wrote: > On Thu, May 29, 2014 at 10:45 PM, Marc Aldorasi <[email protected]> wrote: >> With grep 2.18, the -m option would cause grep to stop reading input >> after printing the requested number of matching lines. With version >> 2.19, grep reads the entire input before exiting. Interestingly, grep >> does not read the entire input if the -c or -C0 options are added in >> addition to -m, and also when using -l or -q instead of -m. I believe >> this is caused by commit 5122195. > > Thanks a lot for the report. Just in time. > I confirm that it's a bug introduced in 2.19. > To test, run "seq 1000000 > million", then > "strace -e read grep 0 million" first using grep-2.18 > (shows just a few read syscalls), and then with 2.19, > which shows grep reading the entire million-line file.
Correction: to reproduce, you'll have to insert -m1 in that grep command. > Here's an incomplete patch. Obviously there's a lot more > to be added, including NEWS and a nontrivial test. This > was introduced by commit v2.18-140-g6f07900
