bug-bash
[Top][All Lists]
Advanced

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

Re: bug with getting an array index or ...


From: Chet Ramey
Subject: Re: bug with getting an array index or ...
Date: Sun, 6 Dec 2015 13:50:06 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:38.0) Gecko/20100101 Thunderbird/38.4.0

On 12/6/15 10:18 AM, konsolebox wrote:
> On Sun, Dec 6, 2015 at 9:38 PM, shawn wilson <ag4ve.us@gmail.com> wrote:
>> declare -a array=(aaaaaaaa bbbbbbbb cccccccc); echo "${!array[@]}";
>> echo "${!array[@]:-}"
>>
>> also, "${!array[@]:foo}" and :+foo and :-foo are all empty as well -
>> I'm pretty sure this is not intended?
>>
> ${!name[@]:-word}, ${!name[@]:+word}, and ${!name[@]:offset:length}
> are not explicitly documented as valid forms of parameter expansion,
> and never has been.

Yes.  The only documented way to get that construct to produce the list of
indices is to use it like ${!array[@]}.

When you use it in a different expansion, you get standard variable
indirection: expand ${array[@]} and try to use it as a variable name.

-- 
``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]