On Wed, May 10, 2023 at 02:07:46PM +0000, Baumann, Moritz wrote: > 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 SMP Fri > Jan 27 02:56:13 UTC 2023 x86_64 Linux > Machine Type: x86_64-alpine-linux-musl > > Bash Version: 5.2 > Patch Level: 15 > Release Status: release > > Description: > When the nounset option is set, and you try to access a key of an > associative array that does not exist, the error message complains > about the key being unbound instead of the array variable. > > Repeat-By: > set -u > declare -r -A myarray=( [foo]='bar' ) > # typo in name of the associative array > echo ${my_array[foo]} > > Expected output: bash: my_array: unbound variable > Actual output: bash: foo: unbound variable
That is correct behaviour: you set myarray[foo], but you tried to expand my_array[foo] that is not set. emanuele6