Configuration Information [Automatically generated, do not change]: Machine: i686 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i686' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i686-pc-linux-gnu' -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -I. -I. -I./include -I./lib -D_FORTIFY_SOURCE=2 -march=i686 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -DDEFAULT_PATH_VALUE='/usr/local/sbin:/usr/local/bin:/usr/bin' -DSTANDARD_UTILS_PATH='/usr/bin' -DSYS_BASHRC='/etc/bash.bashrc' -DSYS_BASH_LOGOUT='/etc/bash.bash_logout' uname output: Linux localhost 3.12.5-1-ARCH #1 SMP PREEMPT Thu Dec 12 13:32:40 CET 2013 i686 GNU/Linux Machine Type: i686-pc-linux-gnu
Bash Version: 4.2 Patch Level: 45 Release Status: release Description: When declaring a global associative array inside a function and assigning a value to it at the same time, then the array is not globally visible. This doesn't happen if I declare the array first and then do the assignment. That is: Buggy?: function f { declare -gA a=([a]=2 [b]=4) } Ok: function f { declare -gA a; a4=([a]=2 [b]=4) } I'm not sure if this is related to this previous report of mine: http://lists.gnu.org/archive/html/bug-bash/2013-09/msg00025.html If it is, at least I could say I've found a workaround :). Repeat-By: function f1 { declare -ga a1=([1]=2 [2]=4) declare -p a1 } function f2 { declare -gA a2=([a]=2 [b]=4) declare -p a2 } function f3 { declare -ga a3; a3=([1]=2 [2]=4) declare -p a3 } function f4 { declare -gA a4; a4=([a]=2 [b]=4) declare -p a4 } declare -A a5=([a]=2 [b]=4) f1 f2 f3 f4 declare -p a1 declare -p a2 declare -p a3 declare -p a4 declare -p a5