bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Can't declare associative global arrays inside function


From: Carlos Pita
Subject: Can't declare associative global arrays inside function
Date: Tue, 10 Sep 2013 13:41:18 -0300

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 netbook 3.10.3-1-ARCH #1 SMP PREEMPT Fri Jul 26
17:13:15 CEST 2013 i686 GNU/Linux
Machine Type: i686-pc-linux-gnu

Bash Version: 4.2
Patch Level: 45
Release Status: release

Description:
  It's not possible to declare an array that is both global and
associative using declare inside a function.

Repeat-By:
  # this doesn't work
  function fun { declare -g -A arr=([A]=1 [B]=2); }; fun; echo
${arr[A]}; unset arr # => empty output

  # this works
  function fun { declare -g arr=([A]=1 [B]=2); }; fun; echo ${arr[A]};
unset arr # => 1



reply via email to

[Prev in Thread] Current Thread [Next in Thread]