morbig icon indicating copy to clipboard operation
morbig copied to clipboard

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

Open treinen opened this issue 5 years ago • 1 comments

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 avatar Mar 25 '19 15:03 treinen

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.

treinen avatar Apr 01 '19 09:04 treinen