* [PATCH] fix backslash added incompatibility after previous patches
@ 2018-04-22 23:16 Ricardo Giorni
0 siblings, 0 replies; only message in thread
From: Ricardo Giorni @ 2018-04-22 23:16 UTC (permalink / raw)
To: zsh-workers
[-- Attachment #1: Type: text/plain, Size: 1459 bytes --]
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
#
[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 2894 bytes --]
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2018-04-22 23:17 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-22 23:16 [PATCH] fix backslash added incompatibility after previous patches Ricardo Giorni
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).