Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: zsh-4.1.1 and trap '...' DEBUG: a bug or a feature?
- X-seq: zsh-workers 19679
- From: Peter Stephenson <pws@xxxxxxx>
- To: "Nelson H. F. Beebe" <beebe@xxxxxxxxxxxxx>, zsh-workers@xxxxxxxxxx (Zsh hackers list)
- Subject: Re: zsh-4.1.1 and trap '...' DEBUG: a bug or a feature?
- Date: Tue, 23 Mar 2004 18:49:17 +0000
- In-reply-to: ""Nelson H. F. Beebe""'s message of "Tue, 23 Mar 2004 10:54:22 MST." <CMM.0.92.0.1080064462.beebe@xxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
"Nelson H. F. Beebe" wrote:
> We are finishing up a book on shell programming,
Oh, you too. (Actually, ours isn't really on programming, it's on
command-line usage.)
> % cat debug-trap
> trap 'echo This is an EXIT trap' EXIT
> trap 'echo This is a DEBUG trap' DEBUG
> pwd
> pwd
> pwd
> pwd
>
> Next zsh-4.1.1 (the latest):
>
> % zsh debug-trap
> This is a DEBUG trap
> /tmp
> This is a DEBUG trap
> /tmp
> This is a DEBUG trap
> /tmp
> This is a DEBUG trap
> /tmp
> This is a DEBUG trap
> This is an EXIT trap
> This is a DEBUG trap
>
> Notice that zsh takes one final DEBUG trap that bash does not.
>
> Is this a bug, or a feature?
Strictly, it's not a bug, as you saw from the docs. The extra DEBUG is
running when the code in the EXIT trap is run. There is (necessarily)
code to prevent recursive running of traps, but it does not extend to
different traps.
However, we can redocument our way out of it --- I would guess no one is
relying on this behaviour. I don't think the current behaviour is
desirable.
I've noticed that we always queue signals when running traps. This
implies ordinary traps (i.e not ZERR, DEBUG, EXIT) are never run inside
one another. We could extend this to all traps, but it's not
necessarily convenient all the time.
The other obvious possibilities are not running other traps only inside
EXIT traps, or not running DEBUG traps inside other traps. There are
also sorts of permutations.
I have't had time to look at how bash and ksh handle these possibilities.
--
Peter Stephenson <pws@xxxxxxx> Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK Tel: +44 (0)1223 692070
**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.
www.mimesweeper.com
**********************************************************************
Messages sorted by:
Reverse Date,
Date,
Thread,
Author