From a51cd62b4567e5c18b4a2b7c98bb3087013afdc3 Mon Sep 17 00:00:00 2001 From: Martijn Dekker Date: Thu, 3 Aug 2017 19:57:04 +0200 Subject: 41484: Make ${(q+)...} quote backsleshes. --- ChangeLog | 5 +++++ Src/utils.c | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 01e3f6a22..0336c8787 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2017-08-03 Peter Stephenson + + * Martijn: 41484: Src/utils.c: ${(q+)...} didn't properly + quote backslashes. + 2017-08-02 Daniel Shahaf * 41479: Completion/Unix/Command/_xz: Complete compressed, diff --git a/Src/utils.c b/Src/utils.c index 1b80e8cb0..5055d69fe 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; -- cgit 1.4.1