zsh-workers
 help / color / mirror / code / Atom feed
From: Ricardo Giorni <ricardo@giorni.co>
To: zsh-workers@zsh.org
Subject: [PATCH] fix backslash added incompatibility after previous patches
Date: Sun, 22 Apr 2018 20:16:51 -0300	[thread overview]
Message-ID: <8AA6B85B-C8FC-41B9-8FA9-FB35E711A387@giorni.co> (raw)

[-- 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 --]

                 reply	other threads:[~2018-04-22 23:17 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8AA6B85B-C8FC-41B9-8FA9-FB35E711A387@giorni.co \
    --to=ricardo@giorni.co \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).