[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: unsetting associative array executes commands
From: |
Greg Wooledge |
Subject: |
Re: unsetting associative array executes commands |
Date: |
Thu, 11 Mar 2021 10:51:02 -0500 |
On Thu, Mar 11, 2021 at 08:06:55AM -0700, Jason A. Donenfeld wrote:
> 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
unicorn:~$ declare -A blah
unicorn:~$ blah['$(DOESNOTEXIST)']=broken
unicorn:~$ for i in "${!blah[@]}"; do unset 'blah[$i]'; done
unicorn:~$ declare -p blah
declare -A blah=()