From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12719 invoked from network); 24 Jan 2004 00:03:37 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 24 Jan 2004 00:03:37 -0000 Received: (qmail 15873 invoked by alias); 24 Jan 2004 00:03:11 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7014 Received: (qmail 15860 invoked from network); 24 Jan 2004 00:03:10 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 24 Jan 2004 00:03:10 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [195.212.29.150] by sunsite.dk (MessageWall 1.0.8) with SMTP; 24 Jan 2004 0:3:10 -0000 Received: from d12relay01.megacenter.de.ibm.com (d12relay01.megacenter.de.ibm.com [9.149.165.180]) by mtagate1.de.ibm.com (8.12.10/8.12.10) with ESMTP id i0O034pS132326; Sat, 24 Jan 2004 00:03:04 GMT Received: from koetsu.lan (d12av02.megacenter.de.ibm.com [9.149.165.228]) by d12relay01.megacenter.de.ibm.com (8.12.10/NCO/VER6.6) with ESMTP id i0O033Nu227792; Sat, 24 Jan 2004 01:03:03 +0100 Received: from localhost (localhost [127.0.0.1]) by koetsu.lan (Postfix) with ESMTP id C0DC8AF045; Fri, 23 Jan 2004 23:47:45 +0000 (GMT) Received: from uk.ibm.com (localhost [127.0.0.1]) by koetsu.lan (Postfix) with ESMTP id DE034AF021; Fri, 23 Jan 2004 23:47:43 +0000 (GMT) Message-ID: <4011B29F.8040304@uk.ibm.com> Date: Fri, 23 Jan 2004 23:47:43 +0000 From: Cosmo Organization: IBM Informix User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031009 X-Accept-Language: en, en-gb, en-us MIME-Version: 1.0 To: Omen Wild Cc: zsh users Subject: Re: Build a variable name from another variable? References: <20040123224220.GB3354@descolada.dartmouth.edu> In-Reply-To: <20040123224220.GB3354@descolada.dartmouth.edu> X-Enigmail-Version: 0.76.7.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS 0.3.12pre8 Omen Wild wrote: > > > > I am not totally sure what it is called, but I want to build a variable > name dynamically, from the contents of another variable. That is, I > have: > > ----- Begin script ----- > barcontents="bar contents" > baz="bar" > > echo $barcontents # <---- effect I want > echo ${${baz}contents} # <---- how I want to get there > ----- End script ----- > > I get this error: bad substitution > > I think the answer involves the (P) flag, as in: > echo ${${(P)baz}contents} Back in the old days, before these fancy complicated shells, I'd just do this: eval echo \$${baz}contents ;-) Cosmo