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


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

Re: delcare -a on a nameref in a function modifies nameref instead of target

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

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

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: delcare -a on a nameref in a function modifies nameref instead of target Grisha Levit <grishalevit@gmail.com> - 2018-07-29 16:04 -0400

#14415 — Re: delcare -a on a nameref in a function modifies nameref instead of target

FromGrisha Levit <grishalevit@gmail.com>
Date2018-07-29 16:04 -0400
SubjectRe: delcare -a on a nameref in a function modifies nameref instead of target
Message-ID<mailman.4394.1532894682.1292.bug-bash@gnu.org>
I think there's a related regression in the latest devel commit. Creating a
local variable with the same name as a higher-scoped nameref pointing to an
unset variable creates a local variable with the name of the target of the
nameref.

Starting with:

    declare -n ref=var
    f() { local ref=Y; declare -p ref var; local; }

This still works fine in both latest and previous:

    $ var=X; f
    declare -- ref="Y"
    declare -- var="X"
    ref=Y

But the behavior in the unset target case changed from the expected:

    $ unset var; f
    declare -- ref="Y"
    bash: declare: var: not found
    ref=Y

to:

    $ unset var; f
    declare -n ref="var"
    declare -- var="Y"
    var=Y

[toc] | [standalone]


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


csiph-web