For the record, in bash 4.2.25 (Ubuntu LTS 12.04) you can work around your
issue with :
printf -v "aa["ind2"]" %s ""
or
printf -v "aa["ind2"]" %s
D
--
Damien Nadé <[email protected]>
Astek Sud-Est pour France Télécom - Orange/OF/DSIF/DFY/SFY/DO
Sophia Antipolis - France / Tel : 04 97 46 28 74
> -----Message d'origine-----
> De : [email protected] [mailto:bug-bash-
> [email protected]] De la part de NBaH
> Envoyé : jeudi 21 novembre 2013 19:04
> À : [email protected]
> Objet : bash 4.3 and 4.2 trouble with associative arrays assigned by
> ``printf -v''
>
> hello,
>
> Configuration Information [Automatically generated, do not change]:
> Machine: x86_64
> OS: linux-gnu
> Compiler: gcc
> Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64'
> -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-unknown-linux-gnu'
> -DCONF_VENDOR='unknown' -DLOCALEDIR='/home/nbah/share/locale'
> -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -DDEBUG -DMALLOC_DEBUG -I. -I.
> -I./include -I./lib -g -O2
> uname output: Linux mymachine 3.2.0-4-amd64 #1 SMP Debian 3.2.51-1
> x86_64 GNU/Linux
> Machine Type: x86_64-unknown-linux-gnu
>
> Bash Version: 4.3
> Patch Level: 0
> Release Status: beta2
>
> Description:
> associative indexes don't appear when assigned by ``printf -v''
> $ declare -A aa
> $ printf -v "aa["ind1"]" "value 1"
> $ printf -v "aa["ind2"]" "value 2"
> $ printf '%s\n' "${!aa[@]}"
>
> $
>
> also :
> Bash Version: 4.2
> Patch Level: 37
> Release Status: release
> empty value in associative array when assigned by ``printf -v'' don't
> "assign" index
> $ declare -A aa
> $ printf -v "aa["ind1"]" "value 1"
> $ printf -v "aa["ind2"]" ""
> $ printf '%s\n' "${!aa[@]}"
> ind1
> $
_________________________________________________________________________________________________________________________
Ce message et ses pieces jointes peuvent contenir des informations
confidentielles ou privilegiees et ne doivent donc
pas etre diffuses, exploites ou copies sans autorisation. Si vous avez recu ce
message par erreur, veuillez le signaler
a l'expediteur et le detruire ainsi que les pieces jointes. Les messages
electroniques etant susceptibles d'alteration,
Orange decline toute responsabilite si ce message a ete altere, deforme ou
falsifie. Merci.
This message and its attachments may contain confidential or privileged
information that may be protected by law;
they should not be distributed, used or copied without authorisation.
If you have received this email in error, please notify the sender and delete
this message and its attachments.
As emails may be altered, Orange is not liable for messages that have been
modified, changed or falsified.
Thank you.