Does bash impose constraints on the characters used in associative-array subscripts? I have successfully used string subscripts that include spaces, but am tripping on a (bug?) when the subscript includes a quotation mark.
bash-5.0$ declare -A x
bash-5.0$ x["bugs"]=yes
bash-5.0$ x["bug's"]=yes
bash-5.0$ for sub in "${!x[@]}"; do echo "$sub:" ${x["$sub"]}; done
bug's: yes
bugs: yes
bash-5.0$ if [[ -v x["bugs"] ]]; then echo exists; else echo does NOT exist; fi
exists
bash-5.0$ if [[ -v x["bug's"] ]]; then echo exists; else echo does NOT exist; fi
does NOT exist
bash-5.0$ unset x[bugs]
bash-5.0$ unset x["bug's"]
bash: unset: `x[bug's]': not a valid identifier
bash-5.0$ bash --version
bash --version
GNU bash, version 5.0.17(1)-release (x86_64-apple-darwin18.7.0)
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
bash-5.0$
[Ignore the syntax coloring - which misinterprets the output.] Notice the assignments proceed successfully, and I can iterate over the array and print its contents. But the second 'if' statement works incorrectly, and the final 'unset' command fails with an error message.
To me, this looks like a bug in bash. Ideas?