Subject: bug#34488: Add sort --limit, or document workarounds for sort|head error messages

From: Pádraig Brady <[email-masked]>
Date: Sun, 17 Feb 2019 18:00:49 -0800

On 15/02/19 14:11, Eric Blake wrote:
> On 2/15/19 3:40 PM, Assaf Gordon wrote:
>> Helo,
>>
>> On 2019-02-15 8:20 a.m., Eric Blake wrote:
>>> On 2/15/19 8:43 AM, 積丹尼 Dan Jacobson wrote:
>>>> sort: write failed: 'standard output': Broken pipe
>>>> sort: write error
>> [...]
>>> Perhaps coreutils should teach 'env' a command-line option to forcefully
>>> reset SIGPIPE back to default behavior [...]   If we
>>> did that, then even if your sh is started with SIGPIPE ignored (so that
>>> the shell itself can't restore default behavior), you could do this
>>> theoretical invocation:
>>>
>>> $ seq 9999 | env --default-signal PIPE sort -n | sed 5q | wc -l
>>> 5
>>
>> That is a nice idea, I could've used it myself couple of times.
>>
>> Attached a suggested patch.
>> If this seems like a good direction, I'll complete it with NEWS/docs/etc.
> 
> Would we also want an easy way to ignore signals? That's a bit less of
> an issue, since you can use 'trap "" $SIG' in the shell; but having the
> symmetry in env may be nice (especially since using 'trap' is asymmetric
> in that you can't force the shell to un-ignore an inherited ignored signal).

I agree that ignore would be nice to add also.

>> Usage is:
>>     env --default-signal=PIPE
>>     env -P     ##shortcut to reset SIGPIPE

BSD has -P for different reasons, so I would avoid that conflict

thanks a lot for working on this guys.
Pádraig