Subject: Re: bug#18750: --line-buffered option doesn't work with --files-with-matches

From: Louis Sautier <[email-masked]>
Date: Tue, 21 Oct 2014 11:27:38 +0200

On 21 October 2014 01:54, Jim Meyering <[email-masked]> wrote:
> On Mon, Oct 20, 2014 at 12:29 AM, Louis Sautier <[email-masked]> wrote:
>> I have no issue with this behaviour, I just wish one could have
>> buffered null-separated output as well.
>>
>> On 19 October 2014 02:43, Norihiro Tanaka <[email-masked]> wrote:
>>> Jim Meyering <[email-masked]> wrote:
>>>> Thanks, but as a stand-alone patch, that makes grep fail to compile,
>>>> because there is one remaining use of the variable whose declaration
>>>> is removed.
>>>
>>> Sorry, I fixed it, and compiled and tested.
>>>
>>>> In any case, there is some ambiguity in the documentation
>>>> about what "line" buffering means with -Z. With -l and -Z, should
>>>> grep --line-buffered flush after printing each <file_name, NUL> pair?
>>>> That's what I'd expect.
>>>
>>> I interprete the means as line buffered option `_IOLBF' of setvbuf, and
>>> I think that many users will expect the behavior.  However, different
>>> interpretations might also be present.
>
> Thanks for the feedback.  What is your use case?
> As I said above, I too would have expected -Z -l --line-buffered to flush
> after each <file_name, NUL> pair.
>
> Though note that the larger change would
> have to update documentation clarifying that this also applies
> to output that may not contain any newline.  It might even prompt
> the addition of a new option name, --buffered, as a
> more-aptly-named synonym for --line-buffered.
>
> P.S., please do not "top post", i.e., reply after the bottom of the
> quoted text, as I have done.
I think --buffered would be more clear, yes. I would use such an
option to run commands on batches of files found by grep such as:
grep --buffered -RlZ pattern /path | xargs -0 -n 100 rm