[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] declare -i
From: |
Dan Douglas |
Subject: |
Re: [Help-bash] declare -i |
Date: |
Thu, 10 May 2012 13:11:26 -0500 |
User-agent: |
KMail/4.8.3 (Linux/3.3.4-pf+; KDE/4.8.3; x86_64; ; ) |
On Thursday, May 10, 2012 09:56:22 AM Greg Wooledge wrote:
> On Thu, May 10, 2012 at 09:52:45AM -0400, Chet Ramey wrote:
> > Where does the man page say it's ok to use negative subscripts when
> > assigning arrays?
>
> Second paragraph of "Arrays":
>
> An indexed array is created automatically if any variable is assigned
> to using the syntax name[subscript]=value. The subscript is treated
> as an arithmetic expression that must evaluate to a number. If
> subscript evaluates to a number less than zero, it is used as an
> offset from one greater than the array's maximum index (so a subcript
> of -1 refers to the last element of the array).
I took this as meaning it applied generally too. It's a new enough feature
everybody still recommends using the keys anyway... in the rare event someone
has a legitimate need for the "last" element, such as using arrays as a
"dequeue".
--
Dan Douglas
- Re: [Help-bash] declare -i, (continued)
- Re: [Help-bash] declare -i, DJ Mills, 2012/05/09
- Re: [Help-bash] declare -i, Greg Wooledge, 2012/05/09
- Re: [Help-bash] declare -i, Chet Ramey, 2012/05/09
- Re: [Help-bash] declare -i, Bill Gradwohl, 2012/05/09
- Re: [Help-bash] declare -i, Dan Douglas, 2012/05/09
- Re: [Help-bash] declare -i, Greg Wooledge, 2012/05/10
- Re: [Help-bash] declare -i, Bill Gradwohl, 2012/05/10
- Re: [Help-bash] declare -i, Chet Ramey, 2012/05/10
- Re: [Help-bash] declare -i, Greg Wooledge, 2012/05/10
- Re: [Help-bash] declare -i, Chet Ramey, 2012/05/10
- Re: [Help-bash] declare -i,
Dan Douglas <=
- Re: [Help-bash] declare -i, Bill Gradwohl, 2012/05/10
- Re: [Help-bash] declare -i, Clark WANG, 2012/05/09
- Re: [Help-bash] declare -i, Chet Ramey, 2012/05/09
- Re: [Help-bash] declare -i, lxnf98mm, 2012/05/09
- Re: [Help-bash] declare -i, Greg Wooledge, 2012/05/09
- Re: [Help-bash] declare -i, Dan Douglas, 2012/05/09
- Re: [Help-bash] declare -i, Chet Ramey, 2012/05/10