help-bash
[Top][All Lists]
Advanced

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

Re: idea about negative indexed array keys


From: Alex fxmbsw7 Ratchev
Subject: Re: idea about negative indexed array keys
Date: Sat, 13 Mar 2021 16:32:33 +0100

correction of text

past week*s*

*and i know it didnt happen with bash 4 cause i dont have bash 4 since
looong*
*who knows what's been*

On Sat, Mar 13, 2021 at 3:43 PM Alex fxmbsw7 Ratchev <fxmbsw7@gmail.com>
wrote:

> this one looks exactly like the one i rememeber
> but there are factical mismatches, it happened in the past week, with bash
> 5.1.4-maint
> but seemfully somewhere else than direct array index
>
> On Sat, Mar 13, 2021 at 3:36 PM Greg Wooledge <greg@wooledge.org> wrote:
>
>> On Fri, Mar 12, 2021 at 05:11:19PM -0500, Eli Schwartz wrote:
>> > On 3/12/21 4:58 PM, Alex fxmbsw7 Ratchev wrote:
>> > > i saw, ${arr[-1]} == syntax error
>> > >
>> > > what about implenting it, -0 is the last -1 is the second last etc
>> > >
>> > > such negative values are already in ${..:<>:<>} implented, as a good
>> small
>> > > statement for the same style
>> >
>> > How did you accomplish the task of getting a syntax error for this? I
>> > managed it with:
>> >
>> > $ declare arr=(foo bar baz "syntax error")
>> > $ echo "${arr[-1]}"; echo "${arr[-2]}"
>> > syntax error
>> > baz
>>
>> unicorn:~$ bash-4.1 -c 'a=(a b c); echo "${a[-1]}"'
>> bash-4.1: a: bad array subscript
>>
>> unicorn:~$ bash-4.2 -c 'a=(a b c); echo "${a[-1]}"'
>> c
>>
>> Is that close enough?
>>
>>


reply via email to

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