I was testing out this new feature and I can't figure out how to handle certain characters in subscripts when the option is on. Without the option, it is possible to escape the `$' in the subscript to achieve the desired result but obviously that does not work if the option *is* on -- is there a different workaround to use or is this a bug with assoc_expand_once?
Specifically, the following characters prove to cause an issue: shopt -s assoc_expand_once declare -A A for k in $'\t' ' '; do (( A[$k]=2 )) declare -p A done # declare -A A=() # declare -A A=() for k in ']' '*' '@'; do (( A[$k]=2 )) done # -bash: ((: A[]]=2: syntax error: invalid arithmetic operator (error token is "]=2") # -bash: A[*]: bad array subscript # -bash: A[@]: bad array subscript for k in $'\t' ' ' ']' '*' '@'; do read "A[$k]" <<< X # or printf -v "A[$k]" X done # -bash: read: `A[ ]': not a valid identifier # -bash: read: `A[ ]': not a valid identifier # -bash: read: `A[]]': not a valid identifier # -bash: A[*]: bad array subscript # -bash: A[@]: bad array subscript for k in ']' '*' '@'; do declare A[$k]=X done # -bash: declare: `A[]]=X': not a valid identifier # -bash: A[*]: bad array subscript # -bash: A[@]: bad array subscript for k in $'\t' ' ' ']'; do unset "A[$k]" done # -bash: unset: `A[ ]': not a valid identifier # -bash: unset: `A[ ]': not a valid identifier # -bash: unset: `A[]]': not a valid identifier for k in '*' '@'; do declare -A A; unset "A[$k]"; declare -p A done # -bash: declare: A: not found # -bash: declare: A: not found