From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26978 invoked from network); 14 Feb 2004 21:24:18 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 14 Feb 2004 21:24:18 -0000 Received: (qmail 13099 invoked by alias); 14 Feb 2004 21:24:02 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7057 Received: (qmail 13085 invoked from network); 14 Feb 2004 21:24:02 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 14 Feb 2004 21:24:02 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [4.11.9.147] by sunsite.dk (MessageWall 1.0.8) with SMTP; 14 Feb 2004 21:24:1 -0000 Received: (from schaefer@localhost) by candle.brasslantern.com (8.11.6/8.11.6) id i1ELO0F15294 for zsh-users@sunsite.dk; Sat, 14 Feb 2004 13:24:00 -0800 X-Authentication-Warning: candle.brasslantern.com: schaefer set sender to schaefer@closedmail.com using -f From: Bart Schaefer Message-Id: <1040214212400.ZM15293@candle.brasslantern.com> Date: Sat, 14 Feb 2004 21:24:00 +0000 In-Reply-To: <200402140959.24015.scowles@earthlink.net> Comments: In reply to "S. Cowles" "help with dereferencing variables" (Feb 14, 9:59am) References: <200402140959.24015.scowles@earthlink.net> X-Mailer: Z-Mail (5.0.0 30July97) To: zsh users Subject: Re: help with dereferencing variables MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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=$(echo "${key}=( ${(@)${(P)val}} )") } eval $b You don't need the $(echo) and the assignment to $b here. It should be enough to do eval ${key}'=( ${(P)val} )' (note placement of single quotes). } # method 2: } ${key}=( ${(@)${(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.