[Top][All Lists]

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

Re: [Help-bash] Remove an empty (null) element in an indexed array

From: Chet Ramey
Subject: Re: [Help-bash] Remove an empty (null) element in an indexed array
Date: Wed, 24 Apr 2013 17:39:57 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:17.0) Gecko/20130307 Thunderbird/17.0.4

On 4/24/13 5:28 PM, Jerry wrote:
> I have been playing around with a few ways to remove an empty or null
> element in an indexed array but nothing seems to works as expected.
> Assume array:  declare -a FOO=(red blue green white black)
> Now, address@hidden would return 5
> If I then do: unset FOO[2}, the "green" element is erased and
> address@hidden returns 4. However, if I do: 
> echo address@hidden
> This is returned:
> red
> blue
> white
> black
> A "null" is returned where the "green" element was.

That looks like a bug.  What version of bash are you using?  I wrote a
quick script similar to yours and could not reproduce your results using
bash-4.2.45 and bash-4.1.11.


``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    address@hidden

reply via email to

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