When I run the following, $ echo 'ASD=123; echo $ASD hi' | bash -s
, the output is exactly what I expect, 123 hi
. But when I use a heredoc like so:
$ bash -s <<EOF
ASD=123; echo $ASD hi
EOF
The output is hi
, which is not what I expect. If I add single quotes around $ASD
, it prints hi
. Why is the variable assignment not working when I use a heredoc?