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

Re: process substitution bug with set -e?

On Mon, 14 Oct 2013 14:41:27 +0200
Vincent Lefevre <vincent@xxxxxxxxxx> wrote:
> #!/usr/bin/env zsh
> set -e
> { /bin/cp } 2>>(sleep 1; cat -n)
> Due to /bin/cp failure and the "set -e", the parent shell exits
> immediately, without waiting for the extra processes:
> ypig% ./zsh-procsubst
> ypig%      1    /bin/cp: missing file operand
>      2  Try '/bin/cp --help' for more information.
> (tested under Debian/unstable).
> Shouldn't the parent shell wait in this case?

I may be thinking too naively here, but...

It's not clear to me this is wrong, anyway (apart from the lack of
documentation).  You're in a non-interactive shell with no job control
(it's possible to mix job control with ERR_EXIT although it seems rather
unnatural).  So the shell has no way cleanly to kill jobs associated
with it.  So it would have to wait until the sleep has finished (or any
other process, however long they took), and it doesn't necessarily know
they're going to exit --- which would be a bug in the script, but if
you've got ERR_EXIT set you probably want to avoid tickling script bugs
when that's in operation.  I think it could be made to wait, but
there's a reasonable argument that as it's already detected the failure
and you've asked it to exit on failure it should just do that.

I certainly don't claim this is a definitive answer.


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