I can create an associative array and assign an integer to a key that contains a single quote in it:
Turn off multiple evaluation* of associative array subscripts with following command and it'll work.
shopt -s assoc_expand_once
* An example showing the default behavior and assoc_expand_once's effect:
$ v1=42 $ v2='$v1' $ declare -A foo $ foo[$v2]= $ declare -p foo declare -A foo=(["\$v1"]="") $ (( foo[$v2]++ )) $ declare -p foo declare -A foo=([42]="1" ["\$v1"]="") $ $ shopt -s assoc_expand_once $ (( foo[$v2]++ )) $ declare -p foo declare -A foo=([42]="1" ["\$v1"]="1")