bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: +=() can be used to set illegal indices


From: Emanuele Torre
Subject: Re: +=() can be used to set illegal indices
Date: Thu, 29 Jun 2023 12:24:28 +0200
User-agent: Mutt/2.2.10 (2023-03-25)

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 .

I think the fix only makes bash error when you use  +=(...)  and, before
the assignment, the max index of the array is already INT_MAX.

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
  declare -a x=([9223372036854775805]="foo")

o/
 emanuele6



reply via email to

[Prev in Thread] Current Thread [Next in Thread]