Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Bug with trap?
- X-seq: zsh-users 15043
- From: Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: Bug with trap?
- Date: Mon, 3 May 2010 20:14:04 +0100
- In-reply-to: <20100503184950.GA21369@xxxxxxxxxxxxxxxxxxxxxxxxxx>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <20100430223857.GA4782@cameron> <20100503184950.GA21369@xxxxxxxxxxxxxxxxxxxxxxxxxx>
On Mon, 3 May 2010 21:49:50 +0300
"Nadav Har'El" <nyh@xxxxxxxxxxxxxxxxxxx> wrote:
> On Fri, Apr 30, 2010, Omari Norman wrote about "Bug with trap?":
> > It seems that the trap builtin with the EXIT argument does not work
> > properly if you have a list inside curly braces and the output is piped
> > to another command. For example:
> >...
> > { trap "echo exit trap running" EXIT} | cat
> >...
> > Thus the trap in the last example simply did not run. You can try this
> > with another command in the trap (e.g. touch, or rm) and you will get
> > the same result: the trap does not run.
> >
> > This is zsh 4.3.6 on Debian 5.0. Is this a bug or am I missing
> > something?
>
> This is not a bug, but rather a result of the way that shells (not just zsh)
> do pipes.
I was wondering along the lines you suggest, but the counterargument is
that if you do:
zsh -fc '{ trap "echo exit trap running" EXIT; exit} | cat'
you get the expected message when the left-hand-side (explicitly) exits.
It's not clear to me it should be different on an implicit exit. Traps
are an area where bugs and features are particularly intertwined. I may
get around to looking at what I think the code is doing. (Any
suggestion of vagueness in that sentence is entirely intentional...)
--
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/
Messages sorted by:
Reverse Date,
Date,
Thread,
Author