There seems to be an issue with the following new bash-5.0 feature:
A nameref name resolution loop in a function now resolves to a variable by
that name in the global scope.
[ Note: "warning: x: circular name reference" messages omitted below. ]
While referencing such a nameref works as desc
FWIW, namerefs in the temporary environment bypass the implemented checks:
$ declare -n ref=var[0]
$ ref=X printenv 'var[0]'
X
When a nameref local to a higher function scope points to a variable in the
temporary environment, that nameref (correctly, it seems) expands to the
value
of the target variable from the temporary environment. However, assignment
to
the nameref modifies the variable from the higher scope, bypassing
When a variable is present in the temporary environment and then declared
local in a function, it seems to not actually make a local variable, in the
sense that the variable does not show up in the output of `local',
unsetting
the variable reveals the variable from the higher scope rather than mark