On 6/29/23 6:24 AM, Emanuele Torre wrote:
The fix in the most recent push did not fix the issue:

   $ x=([9223372036854775805]=foo)
   $ x+=( {1..5} )
   $ echo "${x[@]}"
   3 4 5 foo 1 2

It behaves exactly the same way: no error is printed, some elements are
prepended instead of appended, and there are invalid indices in the
output of  declare -p .

Thanks, good catch. The check really needs to be in the loop that goes
through the words in the compound assignment.


What I would have expected was something like this:

   $ x=([9223372036854775805]=foo)
   $ x+=( {1..5} ); echo "this won't run"
   bash: some "invalid assignment" error
   $ declare -p x # no value gets appended since there was an error

No. Why wouldn't the valid assignments be accepted? If you want

a=(1 2 3)

to be as close as possible to

a[0]=1
a[1]=2
a[2]=3

you have to do it that way.

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