zsh-users
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.stephenson@samsung.com>
To: zsh-users@zsh.org
Subject: Re: process substitution bug with set -e?
Date: Mon, 14 Oct 2013 14:48:38 +0100	[thread overview]
Message-ID: <20131014144838.6ec034dd@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <20131014124126.GA31070@ypig.lip.ens-lyon.fr>

On Mon, 14 Oct 2013 14:41:27 +0200
Vincent Lefevre <vincent@vinc17.net> 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.

pws


  reply	other threads:[~2013-10-14 13:48 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-14 12:41 Vincent Lefevre
2013-10-14 13:48 ` Peter Stephenson [this message]
2013-10-14 15:08   ` Vincent Lefevre
2013-10-14 16:23     ` Bart Schaefer
2013-10-14 16:28     ` Peter Stephenson
2013-10-14 17:47       ` Bart Schaefer
2013-10-15  8:42         ` Peter Stephenson
2013-10-15 14:29           ` Bart Schaefer
2013-10-16 17:53             ` Peter Stephenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20131014144838.6ec034dd@pwslap01u.europe.root.pri \
    --to=p.stephenson@samsung.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).