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: Piotr Grzybowski
Subject: Re: Unsetting all elements of an associative array
Date: Wed, 4 Feb 2015 16:27:28 +0100

 I think you are right, maybe this one should be considered:

diff --git a/lib/sh/shquote.c b/lib/sh/shquote.c
index fff4f81..de05f27 100644
--- a/lib/sh/shquote.c
+++ b/lib/sh/shquote.c
@@ -293,7 +293,7 @@ sh_contains_shell_metas (string)
        case '(': case ')': case '<': case '>':
        case '!': case '{': case '}':           /* reserved words */
        case '*': case '[': case '?': case ']': /* globbing chars */
-       case '^':
+       case '^': case '@':
        case '$': case '`':                     /* expansion chars */
          return (1);
        case '~':                               /* tilde expansion */

 what do you think?

cheers,
pg


On Wed, Feb 4, 2015 at 3:42 PM, Greg Wooledge <wooledg@eeg.ccf.org> wrote:
> 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]