bug-bash
[Top][All Lists]
Advanced

[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:40:42 -0500
User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.2.13) Gecko/20101207 Thunderbird/3.1.7

On 12/20/10 3:52 AM, jens.schmidt35@arcor.de wrote:
>> -u  Treat unset variables as an error when substituting.
>>
>> I think the behaviour is consistent with the documentation.
> 
> The question is rather when to consider a variable set or unset.
> 
> 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.

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/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]