Re: question on retrieving map(-A) value w/indirect name

2018-03-19 Thread Greg Wooledge
On Fri, Mar 16, 2018 at 05:50:04PM -0700, L A Walsh wrote: > 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.

Re: question on retrieving map(-A) value w/indirect name

2018-03-17 Thread L A Walsh
David Margerison wrote: processSrvState() { local cur_up="$1[cur_up]" local max_up="$1[max_up]" if [[ "${!cur_up}" == "${!max_up}" ]] ; then echo ok fi } declare -A foo=([cur_up]=11 [max_up]=11) processSrvState foo # note that the array name must not conflict with any keys

Re: question on retrieving map(-A) value w/indirect name

2018-03-17 Thread David Margerison
On 17 March 2018 at 20:40, L A Walsh wrote: > > I seebut that begs the question, how do you access an array's > members using a var holding the array's name? > > I wanted to be able to do something like have a set of > values in an assoc. map, and pass the name to a generic >

Re: question on retrieving map(-A) value w/indirect name

2018-03-17 Thread David Margerison
On 17 March 2018 at 11:50, 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

Re: question on retrieving map(-A) value w/indirect name

2018-03-17 Thread L A Walsh
Chet Ramey wrote: 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.

Re: question on retrieving map(-A) value w/indirect name

2018-03-16 Thread Chet Ramey
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