Associative arrays seem to be local by default when declared inside a function body, where they should be global. The following code
#!/bin/bash f() { decla
You have already answered your own question with declare -g. The workaround on bash versions < 4.2 is to declare the array outside of the function.
f() { map[y] = foo } declare -A map foo echo "${map[y]}"