zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Re: exit trap and list pipelines
Date: Wed, 9 Nov 2016 21:19:57 -0800	[thread overview]
Message-ID: <161109211957.ZM4353@torch.brasslantern.com> (raw)
In-Reply-To: <1478745377.2440153.783050761.5D9FA45B@webmail.messagingengine.com>

On Nov 9,  9:36pm, Anthony Heading wrote:
}
} Printing '6' here seems wrong?  I think it didn't some years back.
} 
} % zsh -c 'trap "echo hello" EXIT; { :; } | wc -c'
} 6
} hello

zsh-2.6 and zsh-3.0 yeild 0, zsh-4.3.17 prints 6.

The change occured because, where zsh formerly would note that the
right side was an external command and "exec" it (thereby disabling
the exit trap), newer zsh notices that there is a trap and does
another fork so that the trap can execute after wc finishes.  This
means that both sides of the pipe run the trap, whereas before
(and in bash) only one side does so.

However, in the older zsh case, there were circumstances in which
the trap did not execute *at all*.

commit 261193a5b7da4ba36ca146424b000aca27c69235
Author: Peter Stephenson <pws@users.sourceforge.net>
Date:   Fri Mar 30 16:51:54 2001 +0000

    Fix problem with traps not runing if shell exec'd final command

(workers/13851)


  reply	other threads:[~2016-11-10  5:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-10  2:36 Anthony Heading
2016-11-10  5:19 ` Bart Schaefer [this message]
2016-11-10  9:57   ` 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=161109211957.ZM4353@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@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).