From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27085 invoked from network); 18 Sep 2001 17:30:28 -0000 Received: from sunsite.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 18 Sep 2001 17:30:28 -0000 Received: (qmail 19629 invoked by alias); 18 Sep 2001 17:29:59 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 15841 Received: (qmail 19502 invoked from network); 18 Sep 2001 17:29:56 -0000 From: Bart Schaefer Message-Id: <010918102930.ZM7932@candle.brasslantern.com> Date: Tue, 18 Sep 2001 10:29:30 -0700 In-Reply-To: <20010918131416.A13937@fuf.sh.cvut.cz> Comments: In reply to Michal Vitecek "trap for EXIT doesn't catch exit?" (Sep 18, 1:14pm) References: <20010918131416.A13937@fuf.sh.cvut.cz> <674.1000812490@csr.com> In-Reply-To: <674.1000812490@csr.com> Comments: In reply to Peter Stephenson "Re: trap for EXIT doesn't catch exit?" (Sep 18, 12:28pm) X-Mailer: Z-Mail Lite (5.0.0 30July97) To: zsh-workers@sunsite.dk Subject: Re: trap for EXIT doesn't catch exit? Cc: Michal Vitecek MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Sep 18, 12:28pm, Peter Stephenson wrote: > > Probably the correct thing to do here is to pop all the saved EXIT's off > the stack of saved traps, executing them one by one, to simulate exiting > the scope of each function in turn. I'll wait to see if there are comments > before I do that (further discussion should probably go to zsh-workers). I don't think it's sufficient to simulate exiting the scopes, because the traps have to execute as if they're in the scope where they were installed. It may be necessary to actually unwind the stack; at least it's necessary to call endparamscope() and endtrapscope() the correct number of times. The problem is really with the overloading of the exit trap for both return from a function and exit from the shell. In bash, for example, the exit trap is never called when a function returns, only when the shell exits. On the other hand, bash doesn't have the notion of local traps; changing a trap in a bash function changes it globally, and it is not restored when the function returns. We may want to bring this up on the shell@research.att.com list.