Jeff King [off-list ref] writes:
So I think a simpler and more robust version is just this:
{
{ yes || true; } &&
command_expecting_sigpipe; echo $? >status
} | true
We'll keep producing data in "yes" until the pipe is closed. So it will
closed before command_expecting_sigpipe even starts, and there is no
race there. And because we're using "true" on the right-hand side of the
pipe, nothing is read at all from the pipe. So there's no guessing about
how much might have been read.
;-)
Like I said, this won't help our current situation, but after having
spent a little time on it (before realizing that) I figured it was worth
documenting.
It is always fun to ses these clever hacks on the list.
Thanks.