Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #14352 > unrolled thread

namerefs and environment variable names with subscripts

Started byGrisha Levit <grishalevit@gmail.com>
First post2018-07-17 16:44 -0400
Last post2018-07-17 16:44 -0400
Articles 1 — 1 participant

Back to article view | Back to gnu.bash.bug


Contents

  namerefs and environment variable names with subscripts Grisha Levit <grishalevit@gmail.com> - 2018-07-17 16:44 -0400

#14352 — namerefs and environment variable names with subscripts

FromGrisha Levit <grishalevit@gmail.com>
Date2018-07-17 16:44 -0400
Subjectnamerefs and environment variable names with subscripts
Message-ID<mailman.3732.1531860264.1292.bug-bash@gnu.org>
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.

[toc] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web