zsh-workers
 help / color / mirror / code / Atom feed
* Re: Test version before zsh 5.4
       [not found] ` <20170731214745.6f81a0f4@ntlworld.com>
  2017-08-03 11:07   ` Test version before zsh 5.4 Peter Stephenson
@ 2017-08-03 16:00   ` Martijn Dekker
  2017-08-03 17:57     ` Martijn Dekker
  1 sibling, 1 reply; 4+ messages in thread
From: Martijn Dekker @ 2017-08-03 16:00 UTC (permalink / raw)
  To: Peter Stephenson, Zsh hackers list

I found a problem with the shell's generation of C-style shell-quoted
strings ($'...').

% testvar=$'one\\two\n'
breedzicht% set|grep ^testvar
testvar=$'one\two\n'

The backslash is not escaped properly.

- M.


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

* Re: Test version before zsh 5.4
  2017-08-03 16:00   ` Martijn Dekker
@ 2017-08-03 17:57     ` Martijn Dekker
  2017-08-03 20:33       ` Peter Stephenson
  0 siblings, 1 reply; 4+ messages in thread
From: Martijn Dekker @ 2017-08-03 17:57 UTC (permalink / raw)
  To: Peter Stephenson, Zsh hackers list

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

Op 03-08-17 om 18:00 schreef Martijn Dekker:
> I found a problem with the shell's generation of C-style shell-quoted
> strings ($'...').
> 
> % testvar=$'one\\two\n'
> breedzicht% set|grep ^testvar
> testvar=$'one\two\n'
> 
> The backslash is not escaped properly.

A simple fix is attached.

- M.

[-- Attachment #2: quote.patch --]
[-- Type: text/plain, Size: 728 bytes --]

diff --git a/Src/utils.c b/Src/utils.c
index 1b80e8c..5055d69 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -5119,7 +5119,7 @@ niceztrlen(char const *s)
  * If flags contains NICEFLAG_HEAP, use the heap for *outstrp, else
  * zalloc.
  * If flags contsins NICEFLAG_QUOTE, the output is going to be within
- * $'...', so quote "'" with a backslash.
+ * $'...', so quote "'" and "\" with a backslash.
  */
 
 /**/
@@ -5175,6 +5175,10 @@ mb_niceformat(const char *s, FILE *stream, char **outstrp, int flags)
 		fmt = "\\'";
 		newl = 2;
 	    }
+	    else if (c == L'\\' && (flags & NICEFLAG_QUOTE)) {
+		fmt = "\\\\";
+		newl = 2;
+	    }
 	    else
 		fmt = wcs_nicechar_sel(c, &newl, NULL, flags & NICEFLAG_QUOTE);
 	    break;

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

* Re: Test version before zsh 5.4
  2017-08-03 17:57     ` Martijn Dekker
@ 2017-08-03 20:33       ` Peter Stephenson
  0 siblings, 0 replies; 4+ messages in thread
From: Peter Stephenson @ 2017-08-03 20:33 UTC (permalink / raw)
  To: Zsh hackers list

On Thu, 3 Aug 2017 19:57:04 +0200
Martijn Dekker <martijn@inlv.org> wrote:
> Op 03-08-17 om 18:00 schreef Martijn Dekker:
> > I found a problem with the shell's generation of C-style shell-quoted
> > strings ($'...').
> > 
> > % testvar=$'one\\two\n'
> > breedzicht% set|grep ^testvar
> > testvar=$'one\two\n'
> > 
> > The backslash is not escaped properly.
> 
> A simple fix is attached.

Thanks, here's a test.

pws

diff --git a/Test/A03quoting.ztst b/Test/A03quoting.ztst
index da3ce35..be9ca66 100644
--- a/Test/A03quoting.ztst
+++ b/Test/A03quoting.ztst
@@ -78,3 +78,8 @@
  () { print $# } '' "" $''
 0:$'' should not be elided, in common with other empty quotes
 >3
+
+ foo=$'one\\two\n\'buckle\'\tmy\\shoe\n'
+ print -r ${(q+)foo}
+0:Extended minimal quoting of quotes and backslashes
+>$'one\\two\n\'buckle\'\tmy\\shoe\n'


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

* Re: Test version before zsh 5.4
       [not found] ` <20170731214745.6f81a0f4@ntlworld.com>
@ 2017-08-03 11:07   ` Peter Stephenson
  2017-08-03 16:00   ` Martijn Dekker
  1 sibling, 0 replies; 4+ messages in thread
From: Peter Stephenson @ 2017-08-03 11:07 UTC (permalink / raw)
  To: Zsh Hackers' List

On Mon, 31 Jul 2017 21:47:45 +0100
Peter Stephenson <p.w.stephenson@ntlworld.com> wrote:
> You'll find a test version of zsh prior to 5.4 in
> 
> http://www.zsh.org/pub/development/

Sounds like nobody's found any new problems --- I'll probably get around
to making the release on Sunday.

pws


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

end of thread, other threads:[~2017-08-03 20:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20170731204904epcas4p290cb92dadba8d78676093dd6f8411c9f@epcas4p2.samsung.com>
     [not found] ` <20170731214745.6f81a0f4@ntlworld.com>
2017-08-03 11:07   ` Test version before zsh 5.4 Peter Stephenson
2017-08-03 16:00   ` Martijn Dekker
2017-08-03 17:57     ` Martijn Dekker
2017-08-03 20:33       ` Peter Stephenson

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