bug-bash
[Top][All Lists]
Advanced

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

Re: Negative indexes in ${arr[@]:off:length}


From: Greg Wooledge
Subject: Re: Negative indexes in ${arr[@]:off:length}
Date: Wed, 29 Jun 2011 09:01:07 -0400
User-agent: Mutt/1.4.2.3i

On Wed, Jun 29, 2011 at 01:42:06PM +0200, Maarten Billemont wrote:
> If you expand ${arr[@]:1:2}, you get the following:
> values:  [ a | b | c ]
> indexes: 0   1   2   3
> expand:      [ 1   2 ] => b c
>             ^ start from 1
>                   ^ length 2
> 
> I propose we let a negative length iterate backward, so with ${arr[@]:1:-2}, 
> you get the following:
> values:  [ a | b | c ]
> indexes: 0   1   2   3
> expand:    1 ]   [ 2   => a c
>             ^ start from 1
>                   ^ length 2

But if you're starting with element 1, why wouldn't it be "b a"?



reply via email to

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