From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7671 invoked from network); 12 Feb 1999 15:44:32 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 12 Feb 1999 15:44:32 -0000 Received: (qmail 28295 invoked by alias); 12 Feb 1999 15:44:02 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 5356 Received: (qmail 28288 invoked from network); 12 Feb 1999 15:43:54 -0000 From: "Bart Schaefer" Message-Id: <990212074345.ZM8144@candle.brasslantern.com> Date: Fri, 12 Feb 1999 07:43:45 -0800 In-Reply-To: <9902120928.AA34074@ibmth.df.unipi.it> Comments: In reply to Peter Stephenson "PATCH: zsh-3.1.5-pws-7: "$a[@]" with $a unset" (Feb 12, 10:28am) References: <9902120928.AA34074@ibmth.df.unipi.it> X-Mailer: Z-Mail (4.0b.820 20aug96) To: zsh-workers@sunsite.auc.dk Subject: Re: PATCH: zsh-3.1.5-pws-7: "$a[@]" with $a unset MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Feb 12, 10:28am, Peter Stephenson wrote: } Subject: PATCH: zsh-3.1.5-pws-7: "$a[@]" with $a unset } } Sven Wischnowsky wrote: } > % foo() { echo $# } } > % unset a } > % foo $a[@] } > 0 # fine } > % foo "$a[@]" } > 1 # oops That's not an "oops". That's the way it's supposed to work. Try the equivalent code in bash. [schaefer@zagzig zsh-3.1.5-work]$ unset f [schaefer@zagzig zsh-3.1.5-work]$ foo() { echo $#; echo "$@"; } [schaefer@zagzig zsh-3.1.5-work]$ foo "$f[@]" 1 [@] c[1] ksh $ unset f $ foo() { echo $#; echo "$@"; } $ foo "$f[@]" 1 [@] (I had to ssh to my old grad school account to get that ksh example.) zagzig[32] ARGV0=ksh zsh zagzig% unset f zagzig% foo() { echo $#; echo "$@"; } zagzig% foo "$f[@]" 1 [@] } Note that putting `a=()' before would have been a workaround. That's The Right Thing To Do, not a workaround. } Quoted variables only expand to nothing if the @ is present. On a scalar -- which is what `a' is if you've never done `a=()' -- the string $a[@] expands to all the characters in the value of $a; it's the same as just "$a". The quoted-@ magic doesn't apply when slicing a scalar. I don't think we want this patch. -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com