bug-bash
[Top][All Lists]
Advanced

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

Re: need ability to tell if array is associative or not - bug?


From: Chet Ramey
Subject: Re: need ability to tell if array is associative or not - bug?
Date: Fri, 29 Aug 2014 11:59:00 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:24.0) Gecko/20100101 Thunderbird/24.6.0

On 8/29/14, 11:45 AM, Jason Vas Dias wrote:

> Nor does the error happen if indirect expansion is not used:

Just to head off a potential question.  This is not the same as the first
example, since my_array is declared as an associative array.

> $ ( function f()  {       local an_array=$1;     local value='1.0';
>      local v=$value;
>      local ev='['"'"'value'"'"']='"'""$v""'";
>      eval ${an_array}='('"$ev"')'; }; declare -A my_array; set -x; f my_array 
> )
                                        ^^^^^^^^^^^^^^^^^^^
                                        |||||||||||||||||||
> + f my_array
> + local an_array=my_array
> + local value=1.0
> + local v=1.0
> + local 'ev=['\''value'\'']='\''1.0'\'''
> + eval 'my_array=(['\''value'\'']='\''1.0'\'')'
> ++ my_array=(['value']='1.0')
> $

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/



reply via email to

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