ksh: Array slicing incorrect result
This
a=(1 2 3); len=${#a[@]}; echo "${a[*]:0:$len}";
prints 1 2 3
. But this
a=(1 2 3); echo "${a[*]:0:${#a[@]}}";
prints 1 1 2
.
Testing envivonment:
$ ksh --version
version sh (AT&T Research) 93u+m/1.1.0-alpha+a86a7c0b/MOD 2023-03-04
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 17
Regardless of whether a slicing operation on an associative array is meaningful or not, as long as
and
don’t produce identical results, there is still a bug and I’m not happy.
That one does not show a bug; both commands are as expected. In the second one, i[3]==4 (since array indexes start at 0), so
1 2 3 4
is the expected output.