colis-anr / morbig

A static parser for POSIX Shell
Other
192 stars 8 forks source link

falis when a here-document delimiter contains a variable or subshell #89

Open treinen opened 5 years ago

treinen commented 5 years ago

Morbig fails with "Failure: Unsupported expansion in here document delimiter" on the following script

cat << $x
kgjlkfdjgkdflkg
$x

bash accepts it both with with and without --posix, and dash gives an error.

I think that the behaviour of bash is correct since nothing in the standard says that the delimiter word may not contain variables, subshells, or globs. However these are not subject to expansion, as stated in 2.7.4.

treinen commented 5 years ago

this is fixed for a delimiter containing a variable, but it still fails when the delimiter contains a subshell

cat <<$(something)
abc
$(something)

this is refused by dash, but accepted by bash --posix. I think that dash is wrong.