[Top][All Lists]

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

Re: nameref bug?

From: lolilolicon
Subject: Re: nameref bug?
Date: Sat, 30 Aug 2014 11:39:48 +0800

On Sat, Aug 30, 2014 at 11:19 AM, lolilolicon <address@hidden> wrote:
> The following is my test scripts and their output.
> They are very similar, and I do not think they should result in
> different output.
> The output I expected from all of them is:
> v1
> v2
> But as you can see, only 1 in the following 4 cases does it meet my
> expectation. In the other 3 cases, the nameref attribute of the variable
> 'ref' is lost unexpectedly.

It seems to be a namespace / scope problem.

Another test script reveals that without assigning ref explicitly, such
as using the "for ... in" construct, it behaves as expected.

=== script ===
declare -a arr=('dict[k1]' 'dict[k2]')
declare -A dict='([k1]=v1 [k2]=v2)'
declare -n ref
for ref in "address@hidden"; do
  echo $ref

echo $ref
echo $ref

--- output ---

As you see, once ref is assigned explicitly, or indeed, is assigned for
a second time, its nameref attribute is lost.

reply via email to

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