On 8/27/18 12:25 PM, Grisha Levit wrote: > This used to work: > > bash-4.4$ a=0 > bash-4.4$ echo $(( a[a[0]] )) > 0 > bash-4.4$ echo ${a[a[a[0]]]} > 0 > > But is broken in bash-5.0: > > bash-5.0$ a=0 > bash-5.0$ echo ${a[a[a[0]]]} > bash: a[a[0]]: syntax error: invalid arithmetic operator (error token is "]") > bash-5.0$ echo $(( a[a[0]] )) > bash: a[a[0]] : syntax error: invalid arithmetic operator (error token is "] > ")
This is part of changes in bash-5.0 to avoid expanding array subscripts more than one time. After expanding the subscript once, you don't want to expand (or check) nested open and close brackets again -- how do you get literal brackets into an associative array key, for instance? I'll take a look and see if there's an easy way to allow this syntax, which -- you have to admit -- is fairly obscure. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRU c...@case.edu http://tiswww.cwru.edu/~chet/