Re: test '-v' - associative vs. normal array discrepancy - a bug ?
From:
Greg Wooledge
Subject:
Re: test '-v' - associative vs. normal array discrepancy - a bug ?
Date:
Wed, 19 Nov 2014 15:05:06 -0500
User-agent:
Mutt/1.4.2.3i
On Wed, Nov 19, 2014 at 07:59:42PM +0000, Jason Vas Dias wrote:
> [ ${#v[@] -gt 0 ] does not work
> if $v is a normal variable.
Doesn't it? It seems to work for me (once you fix the typo):
imadev:~$ unset v; v=''; test "${#v[@]}" -gt 0 && echo yes
yes
imadev:~$ unset v; v='x'; test "${#v[@]}" -gt 0 && echo yes
yes
imadev:~$ unset v; test "${#v[@]}" -gt 0 && echo yes
imadev:~$
Granted, it's an awkward expression. I'm not arguing against fixing -v.