From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27788 invoked from network); 22 Nov 1999 20:15:28 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 22 Nov 1999 20:15:28 -0000 Received: (qmail 5128 invoked by alias); 22 Nov 1999 20:15:13 -0000 Mailing-List: contact zsh-users-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 2745 Received: (qmail 5117 invoked from network); 22 Nov 1999 20:15:12 -0000 From: "Bart Schaefer" Message-Id: <991122201453.ZM23495@candle.brasslantern.com> Date: Mon, 22 Nov 1999 20:14:53 +0000 In-Reply-To: <19991122190225.A8613@psidev.net> Comments: In reply to Phil Pennock "expansion of nested parameters" (Nov 22, 7:02pm) References: <19991122190225.A8613@psidev.net> X-Mailer: Z-Mail (5.0.0 30July97) To: Phil Pennock , Zsh Users Subject: Re: expansion of nested parameters MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Nov 22, 7:02pm, Phil Pennock wrote: } Subject: expansion of nested parameters } } This is with zsh-3.0.7: } -----------------------------< cut here >------------------------------- } #!/bin/zsh -f } a=foo } wib_foo_ble=Wow } c=\$wib_${a}_ble } print ${(e)c} } print ${(e)\$wib_${a}_ble} } -----------------------------< cut here >------------------------------- } } 1: Why does the second print statement print out the current process ID } from $$ instead of printing the same as the first print statement? ${(e)c} means: Expand ${c}, then apply command substitution etc. to the result of that expansion. Hence ${(e)\$wib_${a}_ble} means: Expand ${\$wib_${a}_ble}, then ... You'll note that ${\$} is the same as ${$} because the command-line parser strips the backslash before the parameter-name interpreter ever gets around to looking at it. ${$} is the same as $$; the rest of the "wib_${a}_ble" stuff is simply ignored once zsh recognizes $$. } 2: Is there a way to do this without using an intermediate variable, as } I've done with $c and without using eval statements? Yeah; it's in the FAQ, question 3.22. What you're asking is a variation: print ${(e)a:+\$wib_${a}_ble} should do it. -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com