[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: List of keys of an associative array
From: |
Pierre Gaston |
Subject: |
Re: List of keys of an associative array |
Date: |
Fri, 31 Dec 2010 11:58:23 +0200 |
On Fri, Dec 31, 2010 at 11:56 AM, <dnade.ext@orange-ftgroup.com> wrote:
> Ha. Indeed, if i use declare –A, it works.
>
>
>
> But why is bash letting me use foo[bar]=something in the first place, if I
> don’t declare foo as an associative array ?
>
> Maybe the bug’s here.
>
>
>
> D
>
>
>
It's because [ ] is an arithmetic context.
In an arithmetic context the content of the variable is evaluated, and a
null string is evaluated to 0, just like when you do echo $((var))