When run in bash, this command:
cat <<EOF
hello \\
world
EOF
will output as I expect:
hello \
world
But this one outputs hello \world (without the newline), and is unexpected:
echo "$(cat <<EOF
hello \\
world
EOF
)"
If I run the second command with dash, then the output is as expected (with a newline).
Why is the newline removed in 2nd command in bash?