On 11/19/14, 2:59 PM, Jason Vas Dias wrote:
> Thanks to all who replied.
>
> I would really like -v to do as it documented to do :
> " -v
> True if the shell variable varname is set (has been assigned a value)
> "
> To me, the fact that -v does not return true if the variable is an array
> and does not have element 0 - or element '0' in the case of assocs -
> means it does not behave as documented.
> Either its behaviour should be changed to return true if an array is
> non-empty (contains ANY non-empty element) or the documentation should
> be changed to document '-v's behaviour for both normal and associative
> arrays.
The problem is that you can only put this stuff in so many places. The
section on arrays says:
"Referencing an array variable without a subscript
is equivalent to referencing element zero."
If you want to use -v to check whether or not an arbitray variable has
a value, use var[@]. Scalars accept the @ subscript, and it works for
unset variables as well.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU [email protected] http://cnswww.cns.cwru.edu/~chet/