From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22647 invoked by alias); 23 Feb 2011 20:35:05 -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: 15825 Received: (qmail 5832 invoked from network); 23 Feb 2011 20:35:03 -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 autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at brasslantern.com does not designate permitted sender hosts) MIME-Version: 1.0 In-Reply-To: References: Date: Wed, 23 Feb 2011 12:29:11 -0800 Message-ID: Subject: Re: Function-scoped parameters? From: Bart Schaefer To: Zsh Users Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On Wednesday, February 23, 2011, Benjamin R. Haskell wrote= : > The use case is that I want to assign a local parameter 'temp' to be set = to the name of a temporary file. =A0If anything goes wrong in the function,= I'd like that temporary file to be removed, but I don't want 'temp' to lea= k out of the function scope. That's what "always" is for. dosomething() { emulate -L zsh local temp=3D$(mktemp) setopt err_return { # ... } always { (( $+temp )) && rm $temp } }