From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23938 invoked by alias); 10 Jul 2010 15:53:17 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 15158 Received: (qmail 14634 invoked from network); 10 Jul 2010 15:53:15 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.1 Received-SPF: pass (ns1.primenet.com.au: SPF record at benizi.com designates 64.130.10.15 as permitted sender) Date: Sat, 10 Jul 2010 11:52:48 -0400 (EDT) From: "Benjamin R. Haskell" To: zsh-users@zsh.org Subject: Re: Assign to parameter in parameter -- opposite of ${(P)name}? In-Reply-To: <20100710145728.GK3043@plenz.com> Message-ID: References: <20100710145728.GK3043@plenz.com> User-Agent: Alpine 2.01 (LNX 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Sat, 10 Jul 2010, Julius Plenz wrote: > Hi, Benjamin! > > * Benjamin R. Haskell [2010-07-10 01:35]: > > but how do you *assign* to a parameter whose name is in a parameter? > > > name=foo > > : ${${(P)name}::=something} > > echo $foo > > # should echo 'something' > > How about: > > zsh> name=foo > zsh> typeset $name=something > zsh> echo $foo > something Thanks. That'll do. I often need the flexibility of the ${name=value} and ${name:=value} constructs, but not in this case. Also, I tended to shy away from defining things via typeset, because it echoes their values if already set. I didn't realize until just now rereading the man page that TYPESET_SILENT exists. And I didn't realize until just testing it that an explicit assignment disables the echo. The usual case where this bites me is when I try to localize a variable that I used outside a function. -- Thanks, Ben