bug-bash
[Top][All Lists]
Advanced

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

Re: Unsetting all elements of an associative array


From: Greg Wooledge
Subject: Re: Unsetting all elements of an associative array
Date: Wed, 4 Feb 2015 09:42:40 -0500
User-agent: Mutt/1.4.2.3i

On Wed, Feb 04, 2015 at 03:37:07PM +0100, Piotr Grzybowski wrote:
> On Wed, Feb 4, 2015 at 2:39 PM, Greg Wooledge <wooledg@eeg.ccf.org> wrote:
> 
> > On that note, today I learned that you are not allowed to use either *
> > or @ as the index of an associative array in bash.  I guess I can see why,
> > but... that's probably going to break something some day.
> 
>  :)
>  of course you can ;-)
> 
> declare -A a; a["@"]="right"; a["*"]="hoping that you are in an empty
> directory";

Huh, that's even stranger than I thought.

imadev:~$ unset a; declare -A a; a=(["@"]=foo [!]=bar); declare -p a
declare -A a='([@]="foo" ["!"]="bar" )'

imadev:~$ unset a; declare -A a='([@]="foo" ["!"]="bar" )'
bash: [@]="foo": invalid associative array key

If the declare -p output is intended to be reusable shell code, then
this is surely a bug.  (Bash 4.3.30.)



reply via email to

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