Re: Unsetting all elements of an associative array
From:
isabella parakiss
Subject:
Re: Unsetting all elements of an associative array
Date:
Thu, 5 Feb 2015 14:06:39 +0100
On 2/4/15, konsolebox <konsolebox@gmail.com> wrote:
> Logically that should only unset the elements of an array and not the
> array variable
> itself since '*' or '@' is more of a wildcard that represents the
> indices. However, bash
> does otherwise:
>
> #define ALL_ELEMENT_SUB(c) ((c) == '@' || (c) == '*')
>
> ...
>
> if (ALL_ELEMENT_SUB (sub[0]) && sub[1] == 0) // If substring is
> just '@' or '*'
> {
> unbind_variable (var->name); // It just removes it.
> return (0);
> }
>
> Bash version is 4.3.33.
>
So, this is completely intended.
May I ask what's the rationale behind this design choice?
I find it very counterintuitive.