[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: declare [-+]n behavior on existing (chained) namerefs
From: |
Piotr Grzybowski |
Subject: |
Re: declare [-+]n behavior on existing (chained) namerefs |
Date: |
Sat, 14 May 2016 18:59:26 +0200 |
On 13 May 2016, at 23:31, Grisha Levit wrote:
> All the behavior inside functions now seems consistent with what is in the
> docs. But the behavior at global scope still seems strange (sorry if this is
> still a WIP):
> Each of the following produces different results in global scope and inside a
> function: [..]
judging from the comments in declare_internal the behaviour in global scope is
intentional, while at the same time in function scope, the local variables are
created unconditionally.
when I type:
declare -n r=a
I would expect a new variable r with nameref attribute to be created pointing
to variable of name a, no matter what kind of wicked chains of namerefs Grisha
created earlier. Concerning
declare +n r=a
I am not sure, but it would seem as logical to just create a variable r of
value a.
After all this is what those command say: declare and assign a variable. If
you want nameref resolving, declare is not the correct place to do it.
Both fixes can be easily done in declare_internal, decision being the
difficult part.
cheers,
pg