On 3/11/21 3:50 PM, Andreas Schwab wrote:
On Mär 11 2021, Chet Ramey wrote:
$ cat x1
declare -A blah
blah['$(DOESNOTEXIST)']=broken
shopt -s assoc_expand_once
touch blah\$
for i in "${!blah[@]}"; do unset blah["$i"]; done
declare -p blah
$ ../bash-5.1-patched/bash ./x1
declare -A blah=()
2021年3月12日(金) 4:37 Alex fxmbsw7 Ratchev :
> maybe implent a shopt -s no_expand_subshells
There is already `shopt -s assoc_expand_once'. With this shell option,
one can write `unset "blah[$i]"'.
But such an option actually doesn't completely solve all similar cases
including the associative array
On Mär 11 2021, Chet Ramey wrote:
> $ cat x1
> declare -A blah
> blah['$(DOESNOTEXIST)']=broken
> shopt -s assoc_expand_once
touch blah\$
> for i in "${!blah[@]}"; do unset blah["$i"]; done
> declare -p blah
> $ ../bash-5.1-patched/bash ./x1
> declare -A blah=()
Andreas.
--
Andreas Schwab, sc
maybe implent a shopt -s no_expand_subshells
On Thu, Mar 11, 2021 at 9:20 PM Chet Ramey wrote:
> On 3/11/21 10:06 AM, Jason A. Donenfeld wrote:
> > This behavior is quite surprising:
>
> The idea is that array subscripts undergo a uniform set of expansions when
> they're used, no matter the cont
On 3/11/21 11:38 AM, Jason A. Donenfeld wrote:
Single quotes with the nested double quote? That's nuts. But okay. I
guess there really is some double expansion eval-like logic happening
with the unset operator.
It's not an `operator' per se, it's a builtin command. That means its
arguments unde
On 3/11/21 10:06 AM, Jason A. Donenfeld wrote:
This behavior is quite surprising:
The idea is that array subscripts undergo a uniform set of expansions when
they're used, no matter the context. Builtins already undergo word
expansions as part of command execution. The result is double expansio
On Thu, Mar 11, 2021 at 09:38:37AM -0700, Jason A. Donenfeld wrote:
> Single quotes with the nested double quote? That's nuts. But okay. I
> guess there really is some double expansion eval-like logic happening
> with the unset operator.
I removed the double quotes, as they serve no purpose there.
Single quotes with the nested double quote? That's nuts. But okay. I
guess there really is some double expansion eval-like logic happening
with the unset operator.
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: DOESNOTEX
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
10 matches
Mail list logo