There is also an issue when doing something like `declare -n r=a' in a
function if the same has been done in a higher scope.  Instead of creating
a new variable r in the function's scope, it modifies the local `a' to be a
self-referencing nameref..

$ declare -nt r=a; f() { declare a; declare -n r=a; declare -p a r; }; f
declare -n a="a"    # ??
declare -nt r="a"   # note the -t.  this is the outer $r, a new one was not
created

In a slightly different version, with `declare -n r; r=a', the function
exits with code 1 after the `r=a' statement:

$ declare -nt r=a; f() { declare a; declare -n r; r=a; declare -p a r; };
f; echo $?
1

Reply via email to