On Tue, Jun 11, 2024 at 6:48 AM Zachary Santer <zsan...@gmail.com> wrote: > > The ( ) within the parameter expansion would be roughly analogous to > the right hand side of a compound assignment statement for an indexed > array. The values found therein would be taken as the indices of array > elements or characters to expand. Trying to set indices for the > indices, i.e. "${array[@]( [10]=1 [20]=5 )}", wouldn't make any sense, > though, so not quite the same construct.
It occurs to me that, if this were to be implemented, arithmetic evaluation should be performed on the contents of the parentheses when this is part of an indexed array expansion, since those indices can only be integers anyway. This would then be the same behavior you get within declare -i -a indeces indeces=( 2#0010 2#1000 ) for instance. So, "${array[@]( 2#0010 2#1000 )}" would have the same effect as "${array[@]( "${indeces[@]}" )}", though arithmetic evaluation was already performed when indeces[@] was assigned a value. Is "${array[@]( "${indeces[@]}" )}" ugly? Does that matter? It seems like a good way to write what's happening. I still have to look up some of the less-commonly-used parameter expansions every time I use them. I think people would kind of "get" this more readily.