From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7692 invoked from network); 23 Mar 2004 18:50:09 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 23 Mar 2004 18:50:09 -0000 Received: (qmail 2942 invoked by alias); 23 Mar 2004 18:50:03 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 19679 Received: (qmail 2917 invoked from network); 23 Mar 2004 18:50:02 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 23 Mar 2004 18:50:02 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [130.225.247.86] by sunsite.dk (MessageWall 1.0.8) with SMTP; 23 Mar 2004 18:50:1 -0000 Received: (qmail 1502 invoked from network); 23 Mar 2004 18:50:01 -0000 Received: from lhuumrelay3.lnd.ops.eu.uu.net (62.189.58.19) by a.mx.sunsite.dk with SMTP; 23 Mar 2004 18:49:51 -0000 Received: from MAILSWEEPER01.csr.com (mailhost1.csr.com [62.189.183.235]) by lhuumrelay3.lnd.ops.eu.uu.net (8.11.0/8.11.0) with ESMTP id i2NInLv26202 for ; Tue, 23 Mar 2004 18:49:22 GMT Received: from EXCHANGE02.csr.com (unverified [192.168.137.45]) by MAILSWEEPER01.csr.com (Content Technologies SMTPRS 4.3.12) with ESMTP id ; Tue, 23 Mar 2004 18:48:55 +0000 Received: from csr.com ([192.168.144.127]) by EXCHANGE02.csr.com with Microsoft SMTPSVC(5.0.2195.6713); Tue, 23 Mar 2004 18:51:49 +0000 To: "Nelson H. F. Beebe" , zsh-workers@sunsite.dk (Zsh hackers list) Subject: Re: zsh-4.1.1 and trap '...' DEBUG: a bug or a feature? In-reply-to: ""Nelson H. F. Beebe""'s message of "Tue, 23 Mar 2004 10:54:22 MST." Date: Tue, 23 Mar 2004 18:49:17 +0000 Message-ID: <232.1080067757@csr.com> From: Peter Stephenson X-OriginalArrivalTime: 23 Mar 2004 18:51:49.0926 (UTC) FILETIME=[E649DC60:01C41107] X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, hits=0.2 required=6.0 tests=EXCUSE_16 autolearn=no version=2.63 X-Spam-Hits: 0.2 "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 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 **********************************************************************