From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28881 invoked from network); 17 Mar 1999 10:34:33 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 17 Mar 1999 10:34:33 -0000 Received: (qmail 12140 invoked by alias); 17 Mar 1999 10:24:18 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 5840 Received: (qmail 12131 invoked from network); 17 Mar 1999 10:24:16 -0000 Message-Id: <9903171008.AA24080@ibmth.df.unipi.it> To: zsh-workers@sunsite.auc.dk Subject: Re: PATCH: param stuff and was: PATCH: 3.1.5-pws-12: _brace_parameter In-Reply-To: ""Andrej Borsenkow""'s message of "Wed, 17 Mar 1999 12:59:19 NFT." <006201be705c$d3291660$21c9ca95@mowp.siemens.ru> Date: Wed, 17 Mar 1999 11:08:21 +0100 From: Peter Stephenson "Andrej Borsenkow" wrote: > bor@itsrm2:~%> foo=(bar baz) > bor@itsrm2:~%> print "${(@)${foo}[1]}" > bar baz > bor@itsrm2:~%> print "${${(@)foo}[1]}" > b > > Could anybody explain, why? It's actually completely predictable, once you know the rule. In the first case the processing is - "${foo}" giving quoted substituion, the word "bar baz" - "${(@)...[1]}" where the ... is the result of the above. This does array indexing on what you have already, because of the (@). What you have already is a single word, so that is the first word of the array and you get that. In the second case, you get - "${(@)foo}", giving the array (bar baz) - "${...[1]}" on the result of that. There is no (@), so this is a scalar substitution, so what we have so far is turned into a single word and the [1] applies to characters in that, giving the `b'. The rule is: Substitution at each level only takes account of its own flags and whether or not it is in double quotes in deciding how to process what it has received from any nested substituion. It knows whether or not that was an array, in case it needs to join the words or select one or more of them, but it has no way of knowing about nested flags and whether it should propagate them. Maybe I can even invent something for the manual, if it's not going to change. -- Peter Stephenson Tel: +39 050 844536 WWW: http://www.ifh.de/~pws/ Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy