[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Error on arithmetic evaluation of `~0`.
From: |
Bize Ma |
Subject: |
Re: Error on arithmetic evaluation of `~0`. |
Date: |
Sat, 29 Dec 2018 01:26:33 -0400 |
Chet Ramey (<chet.ramey@case.edu>) wrote:
> On 12/23/18 12:01 PM, Bize Ma wrote:
>
{…}
> > Both command line above should have printed "hello".
>
> No. 0 is the only valid subscript for a non-array variable. The difference
> between bash and other shells that implement this feature is that bash
> warns about negative subscripts.
>
If you say so: fine for me.
It still irks me a little that a `${var[-1]}` isn't the "last value"
(sometimes!, consistency?).
I haven't seen that documented anywhere, though.