Re: Inconsistency between how subscripting works with the @ array vs. an
From:
Chet Ramey
Subject:
Re: Inconsistency between how subscripting works with the @ array vs. an actual array
Date:
Mon, 11 May 2026 11:56:29 -0400
User-agent:
Mozilla Thunderbird
On 5/11/26 8:44 AM, Stan Marsh wrote:
The goal is to be consistent with the way $1 works, not with the
way ${array[1]} works.
I get that, but I still think it is wrong. But I do realize that it
cannot and will not be fixed. It should be documented, though.
Bash calls this `substring indexing' (because that is what it does with
a scalar variable). The description includes:
"Substring indexing is zero-based unless the positional parame-
ters are used, in which case the indexing starts at 1 by de-
fault."
Note, incidentally, that the upshot of all of this is that the only
way to fix these sorts of problems is via updating the documentation.
Or perhaps reading it.
I'm not upset about this, but I do find it weird. Incidentally, I
suggest that we implement a policy that bug-bash is for actual code
bugs only and that documentation bugs (such as the last few threads
I've posted on) should go in help-bash.
People can post what they think are bugs on bug-bash, even if they think
the bugs are in the documentation.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU chet@case.edu http://tiswww.cwru.edu/~chet/