Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: value of a key pointed by (P) ?
- X-seq: zsh-users 10719
- From: Peter Stephenson <pws@xxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: value of a key pointed by (P) ?
- Date: Fri, 15 Sep 2006 18:56:28 +0100
- In-reply-to: <20060915174734.GA14349@xxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- Organization: Cambridge Silicon Radio
- References: <20060915174734.GA14349@xxxxxxxxxxxxxxxxxx>
Marc Chantreux <marc.chantreux@xxxxxxxxxxxxxxxxxx> wrote:
> typeset -A a
> a=(
> this is
> something special
> for you
> )
> b=a
> k=this
> print ${${(P)b}[$k]}
>
> i expect 'is', i get 'you'. Why ? how to fix ?
The expression generated by ${(P)b} is passed back as an ordinary array, so
it isn't indexed properly by the $k.
I don't think there's an easy answer; you have to resort to something like
eval print '${'$b'[$k]}'
--
Peter Stephenson <pws@xxxxxxx> Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070
To access the latest news from CSR copy this link into a web browser: http://www.csr.com/email_sig.php
Messages sorted by:
Reverse Date,
Date,
Thread,
Author