Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #11961 > unrolled thread

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

Started byChet Ramey <chet.ramey@case.edu>
First post2015-12-06 13:50 -0500
Last post2015-12-06 13:50 -0500
Articles 1 — 1 participant

Back to article view | Back to gnu.bash.bug

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: bug with getting an array index or ... Chet Ramey <chet.ramey@case.edu> - 2015-12-06 13:50 -0500

#11961 — Re: bug with getting an array index or ...

FromChet Ramey <chet.ramey@case.edu>
Date2015-12-06 13:50 -0500
SubjectRe: bug with getting an array index or ...
Message-ID<mailman.1521.1449427816.31583.bug-bash@gnu.org>
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/

[toc] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web