Unseting a value in an associative bash array when the key contains a quote
<p>I have a bash script that uses filenames as keys in an associative array. Some of the filenames have quotes in them and I can't seem to find any way to unset them.</p>

<p>Here's an example replicating the problem from the terminal:</p>

<pre><code>$ declare -A x
$ y="key with spaces"
$ z="key with spaces and ' quote"
$ x[$y]=5   # this works fine
$ x[$z]=44  # as does this
$ echo "${x[$y]}" "${x[$z]}" # no problems here
5 44
$ unset x["$y"] # works
$ unset x["$z"] # does not work
bash: unset: `x[key with spaces and ' quote]': not a valid identifier
$ echo "${x[$y]}" "${x[$z]}" # second key was not deleted
 44
</code></pre>

<p>The file names processed in my script are arbitrary and need to work regardless of what characters they have in them (within reason, at least needs to work with printable characters.) The unset is used to clear a flag on files with certain properties.</p>

<p>How can I get bash to unset these particular keys when they might contain quote symbols?</p>