From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26027 invoked from network); 1 Oct 2001 16:02:58 -0000 Received: from sunsite.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 1 Oct 2001 16:02:58 -0000 Received: (qmail 29855 invoked by alias); 1 Oct 2001 16:02:47 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 15918 Received: (qmail 29835 invoked from network); 1 Oct 2001 16:02:45 -0000 From: Bart Schaefer Message-Id: <1011001160158.ZM23006@candle.brasslantern.com> Date: Mon, 1 Oct 2001 16:01:58 +0000 In-Reply-To: <16272.1001937697@csr.com> Comments: In reply to Peter Stephenson "PATCH: test for trap EXIT fix." (Oct 1, 1:01pm) References: <16272.1001937697@csr.com> X-Mailer: Z-Mail (5.0.0 30July97) To: Peter Stephenson , zsh-workers@sunsite.dk (Zsh hackers list) Subject: Re: PATCH: test for trap EXIT fix. MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Oct 1, 1:01pm, Peter Stephenson wrote: } } The comment notes the following behaviour: } } fn() { } ( trap 'print This is in the top-level function scope.' EXIT } exit } ) } } Wait ... why is that trap at the top-level function scope? It's inside a subshell. Shouldn't the subshell be its own scope? Anyway, that behavior is not consistent with previous versions of zsh, even 4.0.x, so we should think about it pretty carefully. } The subshell exits without ever leaving the scope of fn(), so the EXIT trap } isn't called in this case. Hrm. Try these variants (with `fn' as above): zsh% trap 'print PS1-level' EXIT; fn #1 zsh% (trap 'print PS1-level' EXIT; fn) #2 zsh% trap 'print PS1-level' EXIT; (exit) #3 zsh% function TRAPEXIT { print PS1-level }; (exit) #4 PS1-level zsh% function TRAPEXIT { print PS1-level }; fn #5 zsh% What's the excuse for the PS1-level trap not running any case but #4? -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net