On 7/21/13 10:35 PM, Dan Douglas wrote: > What's the bug? I can't reproduce this and always get "xx" no mater the > option > order. > > I always assumed the -i attribute doesn't get set until after assigning the > values, which is why: > > $ ( declare -ia foo=(1 2 xx 3); echo "${foo[@]}" ) > 1 2 xx 3
The issue is whether or not attributes that determine how the assignment should be treated (-a/-A) or how the variable should be created (-g) are handled specially and affect how the value is expanded. The question is why -i should be omitted from that list. There is a fairly powerful argument for backwards compatibility here: Dan's suggestion of a workaround by quoting the rhs of the assignment statement is a good one. The other side of the argument is consistency. declare -A foo=(whatever) changes how the array indices are expanded. Why should -i be different? Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, ITS, CWRU c...@case.edu http://cnswww.cns.cwru.edu/~chet/