From: Martijn Dekker <martijn@inlv.org>
To: Peter Stephenson <p.w.stephenson@ntlworld.com>,
Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: Test version before zsh 5.4
Date: Thu, 3 Aug 2017 19:57:04 +0200 [thread overview]
Message-ID: <1606b3b3-c462-3616-0bb0-c711d8194941@inlv.org> (raw)
In-Reply-To: <96245589-7b8a-6532-3c9b-85304b0064be@inlv.org>
[-- 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;
next prev parent reply other threads:[~2017-08-03 17:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20170731204904epcas4p290cb92dadba8d78676093dd6f8411c9f@epcas4p2.samsung.com>
[not found] ` <20170731214745.6f81a0f4@ntlworld.com>
2017-08-03 11:07 ` Peter Stephenson
2017-08-03 16:00 ` Martijn Dekker
2017-08-03 17:57 ` Martijn Dekker [this message]
2017-08-03 20:33 ` Peter Stephenson
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=1606b3b3-c462-3616-0bb0-c711d8194941@inlv.org \
--to=martijn@inlv.org \
--cc=p.w.stephenson@ntlworld.com \
--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).