Subject: Re: bug#24941: Early termination bug in grep 2.26

From: Jim Meyering <[email-masked]>
Date: Tue, 15 Nov 2016 16:09:52 -0800

On Tue, Nov 15, 2016 at 3:33 PM, Paul Eggert <[email-masked]> wrote:
> On 11/15/2016 03:13 PM, Jim Meyering wrote:
>>
>>    We should retain the optimization when reading from stdin that is
>> neither a pipe nor a tty.
>
> I am toying with the idea of retaining the optimization only if lseek-to-EOF
> succeeds, a heuristic that is a bit more restrictive. This arguably would
> conform better to the POSIX requirement that when grep exits "the file
> offset in the open file description is properly positioned just past the
> last byte processed by the utility." See the INPUT FILES section of
> <http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap01.html#tag_17_04>.

I like it. That would make the offset in the input file predictable in
those cases.