On Mon, Mar 09, 2015 at 08:18:17PM -0500, vampyre...@gmail.com wrote: > This implies to me that escaping the quotes in the unset line would cause the > array code to see the same thing in both cases. That is, > > unset foo[\"a\'b\"] > > would mean that the pre-array code word expansions would result in foo["a'b"] > being passed to the array code, the same as what that code sees in the > assignment case.
You still have a potential problem with filename expansion (globbing). imadev:~/tmp$ touch fooa imadev:~/tmp$ unset foo imadev:~/tmp$ declare -A foo imadev:~/tmp$ i="a'b"; foo["$i"]=x imadev:~/tmp$ fooa=keepme imadev:~/tmp$ unset foo[\"a\'b\"] imadev:~/tmp$ declare -p foo fooa declare -A foo='(["a'\''b"]="x" )' bash: declare: fooa: not found Since you need a combination of quotes around the entire argument to prevent globbing, and quotes inside the argument to preserve the array index, and a quote that is literally data inside the array index, it's just a gigantic mess. That's why I recommended using a variable to store the index.