zsh-workers
 help / color / mirror / code / Atom feed
* Re: Bad expansion
@ 2002-01-21 19:40 DervishD
  2002-01-21 19:46 ` DervishD
  0 siblings, 1 reply; 7+ messages in thread
From: DervishD @ 2002-01-21 19:40 UTC (permalink / raw)
  To: raul, zefram; +Cc: zsh-workers

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 696 bytes --]

    Hello Zefram :))

>>    # Bad substitution
>>    echo ${${testing[1]}_VALUE}
>echo ${(e):-\$${testing[1]}_VALUE}
>The :-\ is a smiley that means "maybe there ought to be a neater way".

    Are you joking? XDD It works, but, AFAIK, this (apart from the
obvious smiley) means:

    "Expand <NULL> identifier, and, if it is not defined or missing
(which is true), expand the other thing, that is, \$${testing[1]}_VALUE"

    But, why? I mean, maybe there ought to be a neater way ;)))

    Really, I'm not an expert about parameter expansion. Just the
simple fact that you have provided me a solution is magic for me.

    Thanks a lot Zefram :)) And nice smile-like solution ;)))))

    Raúl


^ permalink raw reply	[flat|nested] 7+ messages in thread
* Re: Bad expansion
@ 2002-01-22  0:17 DervishD
  0 siblings, 0 replies; 7+ messages in thread
From: DervishD @ 2002-01-22  0:17 UTC (permalink / raw)
  To: raul, schaefer; +Cc: zsh-workers

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1351 bytes --]

    Hello Bart :)

>> >>    # Bad substitution
>> >>    echo ${${testing[1]}_VALUE}
>> >echo ${(e):-\$${testing[1]}_VALUE}
>> >The :-\ is a smiley that means "maybe there ought to be a neater way".
>>     Are you joking?
>Yes, he is.

    I knew, just a rethoric question ;))))

>>     "Expand <NULL> identifier, and, if it is not defined or missing
>> (which is true), expand the other thing, that is, \$${testing[1]}_VALUE"
>Almost.  You forgot about the (e).  The whole expression means:

    Oh, I see O:)) The expansions... I was misguided by the smiley XDD

>>     Seriously: why am I having the 'bad substitution' error? What am
>> I doing wrong?. This interest me more than the solution.
>Anything that looks like ${${...}} is called a "nested substitution".  The
>stuff inside the outermost ${...} can take one of two forms:
>(1) it can be the name of a parameter (in which case the substitution is
>    not nested, of course), plus an optional [...] subscript;
>(2) it can be another ${...} substitution expression plus an optional
>    subscript.

    Crystal clear now. I didn't understand the rules for nested
substitution on the zsh manual. Thanks a lot :)

    You are of invaluable help, truly. It's people like Zefram and
you that makes me proud of using Linux, Zsh and all that good free
software out there. You're great.

    Raúl


^ permalink raw reply	[flat|nested] 7+ messages in thread
* Bad expansion
@ 2002-01-21 14:56 DervishD
  2002-01-21 14:51 ` Zefram
  0 siblings, 1 reply; 7+ messages in thread
From: DervishD @ 2002-01-21 14:56 UTC (permalink / raw)
  To: Zsh

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 908 bytes --]

    Hello all :))

    I have a doubt with parameter expansion, because I'm getting an
error of 'bad substitution' on the following code

    # Let's assume I have the following array
    testing=(one two three)
    export testing
    export one_VALUE=DD

    # The following line correctly outputs 'one_VALUE'
    echo $testing[1]_VALUE

    # Idem
    echo ${testing[1]}_VALUE

    # Bad substitution
    echo ${${testing[1]}_VALUE}

    The problem is that I will need even further expansion, because I
want to do 'echo ${(P)${testing[1]}_VALUE}', that is, I want the
output of one_VALUE. And, because the rest of the script, I cannot
use directly the value of one_VALUE in the array 'testing'.

    What am I doing wrong? Just in case, I want to do what is
achieved under Bash with ${!${testing[0]}_VALUE}. Please note that
arrays start at 0 under Bash, not at 1.

    Thanks a lot in advance

    Raúl


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2002-01-22  0:04 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-21 19:40 Bad expansion DervishD
2002-01-21 19:46 ` DervishD
2002-01-21 21:31   ` Bart Schaefer
  -- strict thread matches above, loose matches on Subject: below --
2002-01-22  0:17 DervishD
2002-01-21 14:56 DervishD
2002-01-21 14:51 ` Zefram
2002-01-21 17:12   ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).