Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: No pipefail option?



On Sun, 06 Oct 2013 17:36:21 -0700
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> [>workers]
> 
> On Oct 5, 10:31pm, Peter Stephenson wrote:
> }
> } Indeed, if $pipestatus is working as advertised, it really ought to be
> } this simple...
> 
> Unfortunately, $pipestatus is not working as advertised.

Looks that this might not be fatal for the most typical uses of
PIPEFAIL, since I suspect if you've got a loop at the end of the pipe
processing the results in the main shell you'd typically detect errors
at that point.

> See this thread from 2011:
> 
> http://www.zsh.org/mla/workers/2011/msg01394.html
> 
> In particular
> 
> http://www.zsh.org/mla/workers/2011/msg01396.html
> http://www.zsh.org/mla/workers/2011/msg01470.html
> http://www.zsh.org/mla/workers/2011/msg01475.html
> http://www.zsh.org/mla/workers/2011/msg01476.html
> 
> The patch mentined in msg01476 is here:
> 
> http://www.zsh.org/mla/workers//2011/msg01472.html
> 
> But it didn't resolve the issue, so I never committed it.
> 
> The long and short of it is that pipestatus only works reliably when
> all the commands in the pipeline are external programs.

It's not clear to me if (i) the problem is only relevant to the final
stage in the pipeline (as we fork for others anyway) (ii) you need a
complex command rather than a simple builtin to get confused, but
presumably a complex command might be a function as there's nothing
special about jobs run from inside a function (they are not encapsulated
as far as job control is concerned).

I haven't yet quite worked out why it's not possible to detect the point
at which the job is finished and examine the state at that point, so I
can't comment further, but I might look again and ask stupid questions.

pws



Messages sorted by: Reverse Date, Date, Thread, Author