On 6/27/23 10:30 AM, Emanuele Torre wrote:
If an indexed array has no available slots after its last index, +=()
will overflow the last index, and set into an illegal negative index,
effectively prepending values instead of appending them.

Thanks for the report. I think it's reasonable to check for overflow here,
and not to use the convention that negative subscripts count back from the
end.

I think if  INTMAX_MAX - last_index < elements_to_append  , bash should
just error (error similar to setting to a readonly variable).

It should be an assignment error similar to

a[-1]=value

to an empty array.

Chet

--
``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/


Reply via email to