From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27466 invoked from network); 22 Nov 1999 19:35:12 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 22 Nov 1999 19:35:12 -0000 Received: (qmail 411 invoked by alias); 22 Nov 1999 19:34:57 -0000 Mailing-List: contact zsh-users-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 2744 Received: (qmail 404 invoked from network); 22 Nov 1999 19:34:57 -0000 Subject: Re: expansion of nested parameters In-Reply-To: <19991122190225.A8613@psidev.net> from Phil Pennock at "Nov 22, 1999 7: 2:25 pm" To: phil@psidev.net (Phil Pennock) Date: Mon, 22 Nov 1999 19:34:56 +0000 (GMT) Cc: zsh-users@sunsite.auc.dk X-Mailer: ELM [version 2.4ME+ PL48 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-Id: From: Zefram Phil Pennock wrote: >a=foo >wib_foo_ble=Wow >c=\$wib_${a}_ble >print ${(e)c} >1: Why does the second print statement print out the current process ID > from $$ instead of printing the same as the first print statement? Because you put "$" where it was expecting a parameter name, and "$" is in fact a valid parameter name. >2: Is there a way to do this without using an intermediate variable, as > I've done with $c and without using eval statements? Yes. You can use the form "${:-arbitrary string}" to get a $ expansion that expands to an arbitrary string. $ expansions can be used in the string. So you want to do a=foo wib_foo_ble=Wow print ${(e):-\$wib_${a}_ble} This trick is now documented, in zshexpn(1): # ${name:-word} # If name is set and is non-null then substitute its # value; otherwise substitute word. If name is miss- # ing, substitute word. -zefram