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

Bad expansion



    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



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