On Mai 10 2023, Baumann, Moritz wrote: > 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
This is expected. If the array is an indexed array, the subscript is an arithmetic expression. When bash tries to evaluate the subscript, it finds that foo is unbound. -- Andreas Schwab, SUSE Labs, sch...@suse.de GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7 "And now for something completely different."