bug-bash
[Top][All Lists]
Advanced

[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:51:00 +0800

On Sat, Aug 30, 2014 at 11:39 AM, lolilolicon <lolilolicon@gmail.com> wrote:
>
> As you see, once ref is assigned explicitly, or indeed, is assigned for
> a second time, its nameref attribute is lost.

OK, here is the minimum script that demonstrates the bug:

=== script ===
#!/bin/bash
declare var="hello world"
declare -n ref
ref=var
echo $ref
ref=var
echo $ref

--- output ---
hello world
var


The equivalent "1 out of 4" script that works correctly:

#!/bin/bash
declare var="hello world"
func() {
  local -n ref
  ref=var
  echo $ref
  local -n ref  # the workaround
  ref=var
  echo $ref
}
func



reply via email to

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