[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] Why empty key is not allowed?
From: |
Greg Wooledge |
Subject: |
Re: [Help-bash] Why empty key is not allowed? |
Date: |
Mon, 23 Sep 2019 11:26:11 -0400 |
User-agent: |
Mutt/1.10.1 (2018-07-13) |
On Sat, Sep 21, 2019 at 07:57:31PM -0400, Chris F.A. Johnson wrote:
> And empty string IS allowed. You are not using any string; that is not
> allowed.
>
> x[""]=1
Not in bash.
wooledg:~$ declare -A x
wooledg:~$ x[""]=1
bash: x[""]: bad array subscript
wooledg:~$ empty=
wooledg:~$ x[$empty]=1
bash: x[$empty]: bad array subscript
wooledg:~$ x["$empty"]=1
bash: x["$empty"]: bad array subscript
Bash's associative arrays don't allow the empty string as an index.
They never have.