I have an array, and I would like to concatenate a subset of it, passing it along with some text as stdin for other commands to use.
This works in here string but not in here document, even the same code:
declare -a arr=(12 34 56 78 90)
IFS=','
# join a subset of arr by IFS in here string (OK)
cat <<<"${arr[*]:0:3}"
# doesn't work in here doc, all commas are gone. unless joining all elements
cat <<EOF
${arr[*]:0:3}
${arr[*]}
EOF
output:
12,34,56
12 34 56
12,34,56,78,90