zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] fix backslash added incompatibility after previous patch
@ 2018-04-22 23:45 Ricardo Giorni
  2018-04-25 12:09 ` Ricardo Giorni
  0 siblings, 1 reply; 5+ messages in thread
From: Ricardo Giorni @ 2018-04-22 23:45 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 1379 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] 5+ messages in thread

* Re: [PATCH] fix backslash added incompatibility after previous patch
  2018-04-22 23:45 [PATCH] fix backslash added incompatibility after previous patch Ricardo Giorni
@ 2018-04-25 12:09 ` Ricardo Giorni
  2018-04-25 13:56   ` Bart Schaefer
  0 siblings, 1 reply; 5+ messages in thread
From: Ricardo Giorni @ 2018-04-25 12:09 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 850 bytes --]

> On 22 Apr 2018, at 20:45, Ricardo Giorni <ricardo@giorni.co> wrote:
> 
> 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

Adding more background here, after zsh-workers/42355, which updated the way here docs are processed, some open source configuration scripts that used to comment last backslash before new line broke.

What I did on this patch is move the comparison when a backslash is found, not when the new line is found. I added some new tests for this specific scenario.

What was changed on 42355 is still working, as the tests added at the time still shows up.

Can someone review it, please?

—
Ricardo


[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 2894 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] fix backslash added incompatibility after previous patch
  2018-04-25 12:09 ` Ricardo Giorni
@ 2018-04-25 13:56   ` Bart Schaefer
  2018-04-25 14:01     ` Peter Stephenson
  0 siblings, 1 reply; 5+ messages in thread
From: Bart Schaefer @ 2018-04-25 13:56 UTC (permalink / raw)
  To: Ricardo Giorni, zsh-workers

On Wed, Apr 25, 2018 at 5:09 AM, Ricardo Giorni <ricardo@giorni.co> wrote:
>
> Can someone review it, please?

I have checked this and it is OK.  I will commit it after Peter is
relatively sure he's finished with the forking and process group
changes that are also affecting exec.c


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] fix backslash added incompatibility after previous patch
  2018-04-25 13:56   ` Bart Schaefer
@ 2018-04-25 14:01     ` Peter Stephenson
  2018-04-25 14:19       ` Bart Schaefer
  0 siblings, 1 reply; 5+ messages in thread
From: Peter Stephenson @ 2018-04-25 14:01 UTC (permalink / raw)
  To: zsh-workers

On Wed, 25 Apr 2018 06:56:23 -0700
Bart Schaefer <schaefer@brasslantern.com> wrote:
> On Wed, Apr 25, 2018 at 5:09 AM, Ricardo Giorni <ricardo@giorni.co>
> wrote:
> >
> > Can someone review it, please?  
> 
> I have checked this and it is OK.  I will commit it after Peter is
> relatively sure he's finished with the forking and process group
> changes that are also affecting exec.c

I think you can commit it --- the changes currently on the branch are't
going to go in until next week so I've had some experience with them,
and look easy to rebase round this.  Nothing else is currently pending.

pws


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] fix backslash added incompatibility after previous patch
  2018-04-25 14:01     ` Peter Stephenson
@ 2018-04-25 14:19       ` Bart Schaefer
  0 siblings, 0 replies; 5+ messages in thread
From: Bart Schaefer @ 2018-04-25 14:19 UTC (permalink / raw)
  To: zsh-workers

On Wed, Apr 25, 2018 at 7:01 AM, Peter Stephenson
<p.stephenson@samsung.com> wrote:
>
> I think you can commit it --- the changes currently on the branch are't
> going to go in until next week so I've had some experience with them,
> and look easy to rebase round this.  Nothing else is currently pending.

OK.  I saw 42630, 42686, 42684, 42705, and 42708 go onto the master
branch, so I was hesitating.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-04-25 14:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-22 23:45 [PATCH] fix backslash added incompatibility after previous patch Ricardo Giorni
2018-04-25 12:09 ` Ricardo Giorni
2018-04-25 13:56   ` Bart Schaefer
2018-04-25 14:01     ` Peter Stephenson
2018-04-25 14:19       ` Bart Schaefer

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).