bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bug: readonly array that is empty causes error (whereas not empty do


From: Chet Ramey
Subject: Re: bug: readonly array that is empty causes error (whereas not empty does not)
Date: Thu, 7 Jan 2016 15:23:57 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Thunderbird/38.5.0

On 1/7/16 1:54 AM, James Thomas Moon wrote:
> I attempted to reproduce the error.  The closest error I could reproduce is
> slightly different than my original email suggests.
> The problem I reproduced below is an undefined variable.  To the best of my
> recollection, the original error was silent whereas this error, posted
> below, is "unbound variable".  This may lead to a "behaves as expected"
> resolution.

A variable is unset until it has been assigned a value.  An array variable
without any assigned elements is considered unset.  This is how bash has
behaved at least back to bash-3.2.

If there are no positional parameters, "$@" expands to nothing, so it's
no different from not specifying any values in a compound assignment.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/



reply via email to

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