After patch 42355, escaped backslashes on here-documents stopped working. cat <<-HERE foo\\ bar HERE Before patch 42355 (zsh 5.4), and on latest dash and bash: foo\ bar After: foo\ bar — Ricardo diff --git i/Src/exec.c w/Src/exec.c index 1b622d56f..08789cc04 100644 --- i/Src/exec.c +++ w/Src/exec.c @@ -4427,16 +4427,16 @@ gethere(char **strp, int typ) bptr = buf + bsiz; bsiz *= 2; } - if (lexstop) + if (lexstop || c == '\n') break; - if (c == '\n') { - if (!qt && bptr > t && *(bptr - 1) == '\\') { - /* line continuation */ + if (!qt && c == '\\') { + *bptr++ = c; + c = hgetc(); + if (c == '\n') { bptr--; c = hgetc(); continue; - } else - break; + } } *bptr++ = c; c = hgetc(); diff --git i/Test/A04redirect.ztst w/Test/A04redirect.ztst index b5b65cf5d..1e17dddd4 100644 --- i/Test/A04redirect.ztst +++ w/Test/A04redirect.ztst @@ -174,6 +174,30 @@ >some stuff >to test >tab\stripping +>Last line + + heretest() { + print First line + cat <<-HERE + $foo\\ + $foo + some\\ \ + stuff + to\ + test \\ + more backslash craziness\\\\\\\\\ + wild + HERE + print Last line + } + heretest +0:No line continuation in here-document on escaped backslash +>First line +>bar\ +>bar +>some\ stuff +>to test \ +>more backslash craziness\\\\ wild >Last line #