Thank you very much for your effort, testing and support! On 29.08.2020 01:46, Koichi Murase wrote: > 2020-08-28 22:04 Binarus <li...@binarus.de>: >> 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")
This is very interesting. I never have written code like that and therefore had my problem not before making heavy use of namerefs. So I have tested my code in three different bash versions which all are buggy ... I am surprised that a bug of such severity could survive several years. I don't know when 4.3 came out, but my version of 4.4 is from 2016, and 5.1 is not out yet, so the bug survived at least 4 years (not taking into account devel or beta versions, which are not an option for most people). > 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). Thank you very much again for that invaluable information! I am wondering when debian will include bash 5.1. It looks like debian testing and debian unstable are on bash 5.0, so it will probably take several years. Best regards, Binarus