Aside from the variable expansion mentioned in the question's heading, I also experience another alarming issue when reading inline data to <<EOL
... When the data contains a backtick `, it causes an error.
Both are substitution issues, but what and where is the relevant option? ...(and why is the inline read behaving differently?)
Here is the script
#!/bin/bash
echo '==$BASH' | \
while IFS= read -r line ; do echo "# output 1: $line" ;done
echo '==$BASH'>junk
while IFS= read -r line ; do echo "# output 2: $line" ;done <junk
while IFS= read -r line ; do echo "# output 3: $line" ;done <<EOL
==$BASH
EOL
while IFS= read -r line ; do echo "# output 4: $line" ;done <<EOL
`my backtick test
EOL
This is the output
# output 1: ==$BASH
# output 2: ==$BASH
# output 3: ==/bin/bash
...: bad substitution: no closing "`" in `my backtick test