Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: Untokenize before quoting unquoted literal values



% print -r - ${(q+):-foo = bar}|xxd
00000000: 2766 6f6f 208d 2062 6172 270a            'foo . bar'.
% print -r - ${(q+):-foo * bar}|xxd
00000000: 2766 6f6f 2087 2062 6172 270a            'foo . bar'.
% print -r - ${(qqqq):-foo = bar}
$'foo \215 bar'
---
 Src/subst.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/Src/subst.c b/Src/subst.c
index 9e846afa5c..196a1cd8e1 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -4090,13 +4090,16 @@ colonsubscript:
 
 	    if (quotemod > 0) {
 		if (quotetype == QT_QUOTEDZPUTS) {
-		    for (; *ap; ap++)
+		    for (; *ap; ap++) {
+			untokenize(*ap);
 			*ap = quotedzputs(*ap, NULL);
+		    }
 		} else if (quotetype > QT_BACKSLASH) {
 		    int sl;
 		    char *tmp;
 
 		    for (; *ap; ap++) {
+			untokenize(*ap);
 			tmp = quotestring(*ap, quotetype);
 			sl = strlen(tmp);
 			*ap = (char *) zhalloc(pre + sl + post + 1);
@@ -4136,10 +4139,12 @@ colonsubscript:
 		val = dupstring(val), copied = 1;
 	    if (quotemod > 0) {
 		if (quotetype == QT_QUOTEDZPUTS) {
+		    untokenize(val);
 		    val = quotedzputs(val, NULL);
 		} else if (quotetype > QT_BACKSLASH) {
 		    int sl;
 		    char *tmp;
+		    untokenize(val);
 		    tmp = quotestring(val, quotetype);
 		    sl = strlen(tmp);
 		    val = (char *) zhalloc(pre + sl + post + 1);
-- 
2.38.1





Messages sorted by: Reverse Date, Date, Thread, Author