Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: simple substitution?



2009-08-12 13:39:16 +0200, tartifola@xxxxxxxxx:
> 
> Hi,
> I'm trying to understand expansion end substitution and I'm lost in
> what should be a simple substitution. Here my example
> 
> >foo=4
> >echo ${foo}
> 4
> >FO=fo
> >O=o
> >echo \${${FO}${O}}
> ${foo}
> 
> while I was expecting '4'. What am I missing?

eval.

eval "echo \${${FO}${O}}"

or

eval "echo \${$FO$O}"

See also:

echo ${(P)${:-$FO$O}}

or

echo ${(e)${:-\${$FO$O}}}

see:

info zsh 'Parameter Expansion'

-- 
Stephane



Messages sorted by: Reverse Date, Date, Thread, Author