RE: nounset option: Error message points to the wrong variable when accessing associative arrays

2023-05-11 Thread Baumann, Moritz
> > ⚠️ STOP USING [[ -v "assoc[$key]" ]]! DO NOT USE IT! ⚠️ > > > > [...] > > > > Use [[ -v 'assoc[$key]' ]] instead, so that -v can expand the variable > > correctly by itself: > > Thank you for the warning, I somehow forgot about this behavior even > though the manual mentions it explicitly.

RE: nounset option: Error message points to the wrong variable when accessing associative arrays

2023-05-10 Thread Baumann, Moritz
> ⚠️ STOP USING [[ -v "assoc[$key]" ]]! DO NOT USE IT! ⚠️ > > [...] > > Use [[ -v 'assoc[$key]' ]] instead, so that -v can expand the variable > correctly by itself: Thank you for the warning, I somehow forgot about this behavior even though the manual mentions it explicitly. > Also, especiall

RE: nounset option: Error message points to the wrong variable when accessing associative arrays

2023-05-10 Thread Baumann, Moritz
> Anyway, that is still correct behaviour; the reason why that happens is > that when you assign you perform an array expansion on a variable that > is neither a -a nor a -A variable, the variable is treated as a -a > (indexed array) variable. Thank you for the explanation. I was immediately wonde

nounset option: Error message points to the wrong variable when accessing associative arrays

2023-05-10 Thread Baumann, Moritz
Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: linux-musl Compiler: gcc Compilation CFLAGS: -Os -Wformat -Werror=format-security -Werror=int-conversion -DSYS_BASHRC='/etc/bash/bashrc' -g uname output: Linux 9c586e87b370 5.15.90.1-microsoft-standard-WSL2 #1