bug-bash
[Top][All Lists]
Advanced

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

Re: Is this the expected behaviour for nameref in Bash 4.4 now?


From: Jack Kuan
Subject: Re: Is this the expected behaviour for nameref in Bash 4.4 now?
Date: Thu, 20 Oct 2016 19:44:22 -0400

Thanks for replying.

I was expecting that in the second iteration of the loop, the
local var=var_123  command would make var a normal variable again with value "var_123"
and then the local -n var=$var would make var again a nameref to var_123. This seems
to be the behavior of Bash 4.3.

But anyway, it's easy to work around by introducing another variable rather than redefining the nameref var:

set -x

var_123=123
f() {
    while (( $# )); do
        shift
        local var=var_123
        local -n var_ref=$var
    done
}

f one two


On Thu, Oct 20, 2016 at 4:02 PM, Dan Douglas <address@hidden> wrote:
Yes that was an intentional change to require valid identifiers. I can't
say it will always be that way or that there won't at some point be a
workaround. You can stiill use `${!param}' for now to refer to positional
parameters as you always could, but as usual that isn't useful if you
want to assign by reference.


reply via email to

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