From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18555 invoked from network); 15 Feb 2004 04:13:33 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 15 Feb 2004 04:13:33 -0000 Received: (qmail 16186 invoked by alias); 15 Feb 2004 04:13:04 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7059 Received: (qmail 16140 invoked from network); 15 Feb 2004 04:13:04 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 15 Feb 2004 04:13:04 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [207.217.120.126] by sunsite.dk (MessageWall 1.0.8) with SMTP; 15 Feb 2004 4:13:2 -0000 Received: from cpe-24-221-169-78.ca.sprintbbd.net ([24.221.169.78] helo=ckhb.org) by turkey.mail.pas.earthlink.net with esmtp (Exim 3.33 #1) id 1AsDeO-0000Ra-00 for zsh-users@sunsite.dk; Sat, 14 Feb 2004 20:13:01 -0800 From: "S. Cowles" Reply-To: scowles@earthlink.net Organization: personal To: zsh users Subject: Re: help with dereferencing variables Date: Sat, 14 Feb 2004 20:12:32 -0800 User-Agent: KMail/1.5.1 References: <200402140959.24015.scowles@earthlink.net> <1040214212400.ZM15293@candle.brasslantern.com> In-Reply-To: <1040214212400.ZM15293@candle.brasslantern.com> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Description: clearsigned data Content-Disposition: inline Message-Id: <200402142012.51392.scowles@earthlink.net> Many thanks; that was the info I was missing. One small aesthetics prefere= nce=20 following up on your suggestion and I'm away (does not preserve newlines in= =20 the array element assignments): eval ${key}\=3D\( ${(P)val} \) cheers. On Saturday 14 February 2004 13:24, Bart Schaefer wrote: > On Feb 14, 9:59am, S. Cowles wrote: > } > } In the following code, method 1 gives the expected results. Method > } 2, however, breaks with the error: unknown file attribute. Is the > } eval in Method 1 required, or is there a correct syntax to make the > } dereference occur in Method 2 without an eval? > > The short answers are "not precisely" and "no". > > } # method 1: > } b=3D$(echo "${key}=3D( ${(@)${(P)val}} )") > } eval $b > > You don't need the $(echo) and the assignment to $b here. It should be > enough to do > > eval ${key}'=3D( ${(P)val} )' > > (note placement of single quotes). > > } # method 2: > } ${key}=3D( ${(@)${(P)${val}}} ) > > This syntax is not an assignment, because the stuff to the left of the > equals sign is not an identifier name. (This used to work in older > versions of zsh because the variable was expanded before zsh looked > for assignment syntax, but that was incompatible with other shells.) > > Even if this were an assignment, The ${(@)...} is extraneous when the > whole thing is not in double quotes. And you don't need ${(P)${val}}, > just ${(P)val} is enough.