bash-4.3$ a=([9223372036854775806]=1 2 3 4)
bash-4.3$ echo "${!a[@]}"
-9223372036854775808 -9223372036854775807 9223372036854775806 
9223372036854775807

That wraps but as signed longs, which means we get negative
indexes which we can't easily use.

bash-4.3$ echo "${a[@]}"
3 4 1 2
bash-4.3$ for i in "${!a[@]}"; do echo "${a[i]}"; done


1
2
bash-4.3$ echo "${a[-1]}"
2
bash-4.3$ echo "${a[-2]}"
1
bash-4.3$ echo "${a[-3]}"

bash-4.3$ echo "${a[-4]}"

bash-4.3$ echo "${a[@]:0:4}"
1 2
bash-4.3$ echo "${a[@]: -1:1}"

bash-4.3$ echo "${a[@]: -4:1}"


Same with a[9223372036854775807]; a+=(1 2 3)

mksh wraps to 0 at 2^32 and ksh93 at 2^22 (!?).

zsh arrays are not sparse.

-- 
Stephane



Reply via email to