mvdan / sh

A shell parser, formatter, and interpreter with bash support; includes shfmt
https://pkg.go.dev/mvdan.cc/sh/v3
BSD 3-Clause "New" or "Revised" License
6.97k stars 332 forks source link

interp: here-doc backslash is not preserved #1070

Open mochja opened 2 months ago

mochja commented 2 months ago

When a backslash is present inside here-doc it is not preserved in the output(input). See the difference with bash below:

gosh
$ cat << EOF
> test \" test
> EOF
test " test
bash
bash-3.2$ cat << EOF
> test \" test
> EOF
test \" test

Relates to:

mvdan commented 2 months ago

Thanks, this looks like a bug in the parser. I didn't know that heredocs treat backslashes unlike any other part of the language.