bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: unsetting associative array executes commands


From: Chet Ramey
Subject: Re: unsetting associative array executes commands
Date: Thu, 11 Mar 2021 16:03:07 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.8.0

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=()

Sure:

"When  using  a  variable name with a subscript as an argument to a com-
 mand, such as with unset, without using the word expansion  syntax  de-
 scribed above, the argument is subject to pathname expansion.  If path-
 name expansion is not desired, the argument should be quoted."


--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]