On Mon, Apr 17, 2023 at 10:23:17AM -0700, Wiley Young wrote:
> Description:
>         When an array 'a_foo' is created with 'mapfile -d '' -t', it is
> tested with '[[ -v a_foo ]]' and '[[' returns 0. When '-O 1' is added to
> mapfile, '[[ -v a_foo ]]' returns non-0.

It's not specifically the -O1 option.  It's the fact that there's no
element 0.

unicorn:~$ unset a
unicorn:~$ a[1]=foo
unicorn:~$ [[ -v a ]]; echo "$?"
1

I believe [[ -v a ]] is equivalent to [[ -v a[0] ]].

I have never yet seen a justifiable reason to use [[ -v ]].  All I've
ever seen come out of it are bugs and confusion.

Reply via email to