[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
test '-v' - associative vs. normal array discrepancy - a bug ?
From: |
Jason Vas Dias |
Subject: |
test '-v' - associative vs. normal array discrepancy - a bug ? |
Date: |
Wed, 19 Nov 2014 16:20:51 +0000 |
Good day -
Please could anyone explain why the first command below produces no output:
$ ( declare -A a=([a]=1); if [ -v a ]; then echo yes; fi )
$ ( declare -a a=([0]=1); if [ -v a ]; then echo yes; fi )
yes
$
There does not appear to be any documentation about
different behaviour of -v for associative vs. normal arrays:
-v varname
True if the shell variable varname is set (has been
assigned a value).
Should that be ammended to :
-v varname
True if the shell variable varname is not an associative
array and is set
(has been assigned a value).
or is this a bug with -v ?
I'm using bash-4.3.30(1) , but it appears also to be an issue with
bash-4.3.11(1) .
Regards,
Jason
- test '-v' - associative vs. normal array discrepancy - a bug ?,
Jason Vas Dias <=
- Re: test '-v' - associative vs. normal array discrepancy - a bug ?, Greg Wooledge, 2014/11/19
- Re: test '-v' - associative vs. normal array discrepancy - a bug ?, Piotr Grzybowski, 2014/11/19
- Re: test '-v' - associative vs. normal array discrepancy - a bug ?, Chet Ramey, 2014/11/19
- Re: test '-v' - associative vs. normal array discrepancy - a bug ?, Piotr Grzybowski, 2014/11/19
- Re: test '-v' - associative vs. normal array discrepancy - a bug ?, Jason Vas Dias, 2014/11/19
- Re: test '-v' - associative vs. normal array discrepancy - a bug ?, Greg Wooledge, 2014/11/19
- Re: test '-v' - associative vs. normal array discrepancy - a bug ?, Eduardo A . Bustamante López, 2014/11/19
- Re: test '-v' - associative vs. normal array discrepancy - a bug ?, Greg Wooledge, 2014/11/19
- Re: test '-v' - associative vs. normal array discrepancy - a bug ?, Piotr Grzybowski, 2014/11/19
- Re: test '-v' - associative vs. normal array discrepancy - a bug ?, Greg Wooledge, 2014/11/19