On 10/4/21 10:17 AM, Léa Gris wrote:
Found out that the declare statement does not properly set all variable
flags before assign values:
unset arr
declare -i -a arr=(1 2 3)
declare -p arr
declare -ai arr=([0]="1" [1]="2" [2]="3")
this is ok
declare +i -a arr=(hello world)
declare -p arr
declare -a arr=([0]="0" [1]="0")
this is not ok as arr assignment was handled as integers
It's an interesting order-of-operations question. You can make a case that
the shell should unset the attributes before expanding the words in the
compound assignment statement, since we special-case setting the attributes
for declaration commands. Let me look at that.
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/