[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: List of keys of an associative array
From: |
dnade.ext |
Subject: |
RE: List of keys of an associative array |
Date: |
Fri, 31 Dec 2010 10:56:35 +0100 |
Ha. Indeed, if i use declare –A, it works.
But why is bash letting me use foo[bar]=something in the first place, if I
don’t declare foo as an associative array ?
Maybe the bug’s here.
D
--
Damien Nadé <dnade.ext@orange-ftgroup.com>
Astek Sud-Est pour France Télécom - FT/TGPF/OPF/PORTAIL/DOP/DEV/EAQS
Sophia Antipolis - France / Tel : 04 97 12 86 20
De : Pierre Gaston [mailto:pierre.gaston@gmail.com]
Envoyé : vendredi 31 décembre 2010 10:52
À : NADE Damien Ext DMGP/PORTAIL
Cc : bug-bash@gnu.org
Objet : Re: List of keys of an associative array
On Fri, Dec 31, 2010 at 11:38 AM,
<dnade.ext@orange-ftgroup.com<mailto:dnade.ext@orange-ftgroup.com>> wrote:
Hello
For regular arrays, we can get the list of keys by using the form
${!some_array[@]}.
But this just doesn’t work for associative arrays.
${!some_associative_array[@]} is actually 0. Is that a bug ?
Is there another way to get the list of keys available in an associative array ?
$ declare -A a;a[foo]=bar;a[baz]=bux;echo ${!a[@]}
baz foo
*********************************
This message and any attachments (the "message") are confidential and intended
solely for the addressees.
Any unauthorised use or dissemination is prohibited.
Messages are susceptible to alteration.
France Telecom Group shall not be liable for the message if altered, changed or
falsified.
If you are not the intended addressee of this message, please cancel it
immediately and inform the sender.
********************************