bug-bash
[Top][All Lists]
Advanced

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

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


From: Grisha Levit
Subject: Re: delcare -a on a nameref in a function modifies nameref instead of target
Date: Sun, 29 Jul 2018 16:04:25 -0400

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



reply via email to

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