From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14993 invoked from network); 31 Dec 2002 04:03:11 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 31 Dec 2002 04:03:11 -0000 Received: (qmail 21616 invoked by alias); 31 Dec 2002 04:03:05 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 18042 Received: (qmail 21603 invoked from network); 31 Dec 2002 04:03:04 -0000 From: "Bart Schaefer" Message-Id: <1021231040236.ZM25275@candle.brasslantern.com> Date: Tue, 31 Dec 2002 04:02:36 +0000 In-Reply-To: Comments: In reply to tim_smithers@mlc.com.au "Bug/Caveat for local variables in functions" (Dec 31, 12:54pm) References: X-Mailer: Z-Mail (5.0.0 30July97) To: zsh-workers@sunsite.dk Subject: Re: Bug/Caveat for local variables in functions MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Dec 31, 12:54pm, tim_smithers@mlc.com.au wrote: } } You can't create a local variable with the same name as a special var. Yes, you can. Yout just have to tell zsh to make the local non-special. testit() { local -h path=foo echo $path } } testit() } { } local path=foo } echo $path } } } } this echo's your path, not 'foo'. You don't get any warnings about the } assignment not working etc. What version of zsh do you have? Without the -h option, I get this: testit:local:2: path: can't assign initial value for array } The main reason I found it was porting some shell which works in ksh and } bash to zsh compliant (which has a "path" variable). Usually the quickest way to do this is just to place emulate -L sh at the top of the script. If you're really _porting_ to native zsh mode, rather than wanting to have zsh execute a Bourne shell script, then you may have a lot more changes to make than just adding -h to locals. For example, you're probably also going to have to change variable references from $VAR to $=VAR (when not quoted), to get sh-style word splitting. -- 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