bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

namerefs and environment variable names with subscripts


From: Grisha Levit
Subject: namerefs and environment variable names with subscripts
Date: Tue, 17 Jul 2018 16:44:07 -0400

The following commands:

    declare -n r=v[0]
    v=(X); r=Y
    declare -p ${!v*}
    printf "%s: <%s>\n" "r" "$r" "v" "$v"

Will normally produce the following output:

    declare -a v=([0]="Y")
    r: <Y>
    v: <Y>

However, if we start bash with `v[0]' already in the environment, such as with:

    env 'v[0]=' $BASH

The behavior changes, and the output is:

    declare -a v=([0]="X")
    declare -x v[0]="Y"
    r: <Y>
    v: <X>

I would expect namerefs to ignore any variables with the literal name
`v[0]' in the environment rather than follow them.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]