From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4907 invoked from network); 16 Jun 2000 12:21:41 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 16 Jun 2000 12:21:41 -0000 Received: (qmail 15765 invoked by alias); 16 Jun 2000 12:21:26 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 11944 Received: (qmail 15756 invoked from network); 16 Jun 2000 12:21:26 -0000 Date: Fri, 16 Jun 2000 13:20:54 +0100 From: Peter Stephenson Subject: Re: PATCH: Re: expansion In-reply-to: "Your message of Fri, 16 Jun 2000 13:22:10 +0200." <200006161122.NAA30744@beta.informatik.hu-berlin.de> To: zsh-workers@sunsite.auc.dk (Zsh hackers list) Message-id: <0FW8002NDYAS0Z@la-la.cambridgesiliconradio.com> Content-transfer-encoding: 7BIT Sven wrote: > What's going on here? With -f: > % a='a{b,c}d' > % setopt braceccl > % b=( ${${(q)a}:gs/\\{/{/:gs/\\}/}/} ) > % echo $b > a,d abd acd > > Oops. (Yes, works with just `echo ${${(q)a}...}', too.) Yes, I'd use this: print ${${(q)a}:gs/\\\{/\{/:gs/\\\}/\}/} to make sure all the relevant braces are quoted, or perhaps even better (pattern matching is better about untokenising, because it only needs to do it once while parsing): print ${${(q)a}//(#b)\\([{}])/$match[1]} This is not very well handled at present; all sorts of things are a bit more heavily tokenised than you might want at various places in paramsubst(), because it's very hard to work out in the middle of all the other streams of logic about substitution. There's another glitch with braces I haven't looked at but I had to work around in the parameter tests (possibly the most boring piece of zsh code ever written): % array=(once bitten twice shy) % print IF{${array},THEN}ELSE IF{once bitten twice shy,THEN}ELSE Double-quoting ${array} fixes it, even more bizarrely. This doesn't depend on braceccl. What's more, the full expansion works with RCEXPANDPARAM: % print IF{${^array},THEN}ELSE IFonceELSE IFTHENELSE IFbittenELSE IFTHENELSE IFtwiceELSE IFTHENELSE IFshyELSE IFTHENELSE -- Peter Stephenson Cambridge Silicon Radio, Unit 300, Science Park, Milton Road, Cambridge, CB4 0XL, UK Tel: +44 (0)1223 392070