bug-bash
[Top][All Lists]
Advanced

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

Re: building arrays from non array variables using 'array[${#array[@]}]=


From: Chet Ramey
Subject: Re: building arrays from non array variables using 'array[${#array[@]}]='
Date: Sun, 24 Jan 2010 15:19:55 -0500
User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.1.7) Gecko/20100111 Lightning/1.0b1 Thunderbird/3.0.1

On 1/24/10 5:13 AM, Mart Frauenlob wrote:
> Hello,
> 
> I'd like to ask, if the behavior of indexed array assignment using the
> form: 'array[${#array[@]}]=' is as expected.

Thanks for the report.  The question is what ${#array[@]} should return
when it refers to a scalar variable that has not been assigned a value.
Previous versions of bash returned 1, not checking whether or not the
variable is set; the right answer is 0 if the variable is not set and 1
otherwise.

Any official change will probably wait until bash-4.2.  I have attached a
patch to evaluate, though.

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/

Attachment: unset-var-length
Description: Text document


reply via email to

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