2020-08-28 22:04 Binarus <[email protected]>:
> Description:
> ------------
>
> Under certain circumstances, assignments of namerefs to local variables
> in functions behaves in a way which makes namerefs completely useless.
> Furthermore, the behavior is not consistent.
This is actually not related to namerefs and has already been fixed in
Bash 5.1 and the devel branch. Think about the following codes:
a=1; f1() { local a=$a; local; }; f1
a=2; f2() { local -a a=("$a"); local; }; f2
The results for `f1' are the same for all the Bash versions
2.0..devel, but the results for `f2' varies in versions. Here is the
summary of the results from the different versions of Bash:
- 2.0..3.0: f1: a=1, f2: a=([0]="1")
- 3.1: f2: a=1, f2: a=([0]="")
- 3.2..4.2: f1: a=1, f2: a=([0]="1")
- 4.3..5.0: f1: a=1, f2: a=([0]="")
- 5.1..dev: f1: a=1, f2: a=([0]="1")
I checked the detailed changes. The behavior of `f2' in 3.1 was
reported as a bug in the following thread.
https://lists.gnu.org/archive/html/bug-bash/2006-05/msg00025.html
It was fixed in 8b35878f (commit bash-20060504 snapshot). However,
the bug seems to be introduced again in 36eb585c (commit bash-20121221
snapshot). This regression has been reported at
https://savannah.gnu.org/support/index.php?109669
Finally, it was again fixed in c6c7ae81 (commit bash-20200427
snapshot).
--
Koichi