|
| From: | Jason A. Donenfeld |
| Subject: | unsetting associative array executes commands |
| Date: | Thu, 11 Mar 2021 08:06:55 -0700 |
This behavior is quite surprising:
$ declare -A blah
$ blah['$(DOESNOTEXIST)']=broken
$ for i in "${!blah[@]}"; do echo "$i"; done
$(DOESNOTEXIST)
$ for i in "${!blah[@]}"; do unset blah["$i"]; done
bash: DOESNOTEXIST: command not found
bash: unset: [$(DOESNOTEXIST)]: bad array subscript
I wouldn't have anticipated the double expansion of "$i" there.
Is this a bug? Bash 5.1p4.
| [Prev in Thread] | Current Thread | [Next in Thread] |