From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2155 invoked by alias); 23 Feb 2011 18:12:48 -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: 15821 Received: (qmail 3830 invoked from network); 23 Feb 2011 18:12:37 -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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.1 Received-SPF: pass (ns1.primenet.com.au: SPF record at benizi.com designates 64.130.10.15 as permitted sender) Date: Wed, 23 Feb 2011 13:03:20 -0500 (EST) From: "Benjamin R. Haskell" To: Zsh Users Subject: Function-scoped parameters? Message-ID: User-Agent: Alpine 2.01 (LNX 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; format=flowed; charset=US-ASCII This doesn't work, probably unsurprisingly. But is there a way to accomplish it? function () { emulate -L zsh local x=asdf trap 'echo x is ${x:-unset}' EXIT } The use case is that I want to assign a local parameter 'temp' to be set to the name of a temporary file. If anything goes wrong in the function, I'd like that temporary file to be removed, but I don't want 'temp' to leak out of the function scope. e.g.: dosomething () { emulate -L zsh local temp=$(mktemp) setopt err_return trap '(( $+temp )) && rm $temp' EXIT # ... } -- Best, Ben