In the code below, variable X is output normally.
# cat a.sh X=world echo 'hello' $X # cat a.sh | bash hello world But, using here doc, variable X is not displayed.
# cat <<EOF | bash > X=world > echo 'hello' $X > EOF hello # bash -s <<EOF > X=world > echo 'hello' $X > EOF hello What made this difference?