On Sat, Aug 30, 2014 at 11:39 AM, lolilolicon <loliloli...@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