On 5/21/23 5:01 PM, Martin D Kealey wrote:
1. ${array[@]:start:count} can under some circumstances return elements with indeces >= start+count, completely contravening expectations from other programming languages. There should be a `declare` or `local` option to fix that, and/or a shopt setting.
In the presence of sparse arrays, sure. It's supposed to return `count' elements, not "the number of elements between array[start] and array[start+count]." If you want that, isn't it easy enough to initialize the elements so you don't have a sparse array?
2. ${#array[@]} gives the number of elements rather than the last index (minus 1). Being able to declare an array as non-sparse (so that all gaps "exist" with some default value) would fix this.
Again, it seems easy enough to initialize your arrays to whatever default value you choose if you want this. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRU c...@case.edu http://tiswww.cwru.edu/~chet/