[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: question on retrieving map(-A) value w/indirect name
From: |
Chet Ramey |
Subject: |
Re: question on retrieving map(-A) value w/indirect name |
Date: |
Fri, 16 Mar 2018 23:37:09 -0400 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 |
On 3/16/18 8:50 PM, L A Walsh wrote:
>
> I'm a bit confused ...
> If I have assoc-array:
>
> declare -A foo=([one]=11 [two]=22)
>
> and am passing name in another var, like "fee"
>
> fee=foo
>
> I tried echoing the val:
>
> echo ${!fee[one]}
>
> but got nothing -- tried a few other syntaxes.
This has come up a number of times. Here's a message from 2002 explaining
the details:
https://lists.gnu.org/archive/html/bug-bash/2002-08/msg00119.html
> Question -- why did '!' replace the 2nd $ if it doesn't
> work in arrays?
It does, but differently from how you expect.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU chet@case.edu http://tiswww.cwru.edu/~chet/