From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14632 invoked by alias); 9 Sep 2010 09:56:17 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 15378 Received: (qmail 501 invoked from network); 9 Sep 2010 09:56:15 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at csr.com does not designate permitted sender hosts) Date: Thu, 9 Sep 2010 10:56:08 +0100 From: Peter Stephenson To: zsh-users@zsh.org Subject: Re: trap does not work in a trap function? Message-ID: <20100909105608.453fd843@pwslap01u.europe.root.pri> In-Reply-To: References: <20100909080214.76320@gmx.net> <20100909081733.76300@gmx.net> <20100909095753.5473e833@pwslap01u.europe.root.pri> Organization: Cambridge Silicon Radio X-Mailer: Claws Mail 3.7.6 (GTK+ 2.18.9; i686-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 09 Sep 2010 09:56:08.0885 (UTC) FILETIME=[3A07F650:01CB5005] X-Scanned-By: MailControl A-06-00-00 (www.mailcontrol.com) on 10.68.0.118 On Thu, 9 Sep 2010 11:44:49 +0200 Mikael Magnusson wrote: > Could you also use "SIGEXIT() shutdown" and "unfunction SIGEXIT" > instead, regardless of the amount of function nesting? (It seems to > work when I try it). What's supposed to happen is the trap, however it is set, is saved and unset during the function, then restored afterwards (before the scope in which the function's EXIT trap is run, hence the workaround). So this isn't supposed to work. I get the following: % TRAPEXIT() { echo This is the exit trap; } % fn() { unfunction TRAPEXIT; } % fn fn:unfunction: no such hash table element: TRAPEXIT % functions TRAPEXIT TRAPEXIT () { echo This is the exit trap } % exit This is the exit trap -- Peter Stephenson Software Engineer Tel: +44 (0)1223 692070 Cambridge Silicon Radio Limited Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom