From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2796 invoked from network); 14 Feb 2004 18:00:23 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 14 Feb 2004 18:00:23 -0000 Received: (qmail 12972 invoked by alias); 14 Feb 2004 17:59:30 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7055 Received: (qmail 12942 invoked from network); 14 Feb 2004 17:59:29 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 14 Feb 2004 17:59:29 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [207.217.120.74] by sunsite.dk (MessageWall 1.0.8) with SMTP; 14 Feb 2004 17:59:28 -0000 Received: from cpe-24-221-169-78.ca.sprintbbd.net ([24.221.169.78] helo=ckhb.org) by falcon.mail.pas.earthlink.net with esmtp (Exim 3.33 #1) id 1As44d-0004yY-00 for zsh-users@sunsite.dk; Sat, 14 Feb 2004 09:59:27 -0800 From: "S. Cowles" Reply-To: scowles@earthlink.net Organization: personal To: zsh users Subject: help with dereferencing variables Date: Sat, 14 Feb 2004 09:59:20 -0800 User-Agent: KMail/1.5.1 MIME-Version: 1.0 Content-Type: Text/Plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Content-Description: clearsigned data Content-Disposition: inline Message-Id: <200402140959.24015.scowles@earthlink.net> In the following code, method 1 gives the expected results. Method 2,=20 however, breaks with the error: unknown file attribute. Is the eval in=20 Method 1 required, or is there a correct syntax to make the dereference occ= ur=20 in Method 2 without an eval? (This is a code fragment of a routine that will assign array values to=20 parameters.) Thanks, scowles at earthlink dot net #!/bin/zsh # variable 1 initialize. m1=3D # variable 1 values. m2=3D" /ld1 /ld2 " # variable 2 initialize. m3=3D # variable 2 values. m4=3D" /pk1 /pk2 " # correspondence matrix cm=3D" m1 m2 m3 m4 " rows=3D${#${(f)cm}} for (( row =3D 1 ; $row <=3D $rows ; row++ )) do key=3D${${=3D${${(f)cm}[${row}]}}[1]} val=3D${${=3D${${(f)cm}[${row}]}}[2]} # method 1: b=3D$(echo "${key}=3D( ${(@)${(P)val}} )") eval $b echo " >${key}<: ${(P)${key}}" # method 2: ${key}=3D( ${(@)${(P)${val}}} ) echo " >${key}<: ${(P)${key}}" done exit 0