[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Referencing empty array with "set -u" active throws error
From: |
Chet Ramey |
Subject: |
Re: Referencing empty array with "set -u" active throws error |
Date: |
Mon, 20 Dec 2010 08:55:45 -0500 |
> > For me, an empty string (or empty commadline) is as set or as
> > unset as an empty array. But I don't get an "unbound error" when
> > accessing an empty string (or empty commandline), and I get one
> > when accessing an empty array.
>
> As the man page says:
>
> A parameter is set if it has been assigned a value. The null string is
> a valid value.
>
> Maybe I should add that an array has to have at least one index assigned
> to be considered set.
>
> The positional parameters are a special case, since that's what Posix
> decided.
I spoke too soon again. The manual page also says:
An array variable is considered set if a subscript has been assigned a
value. The null string is a valid value.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/