summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--Src/builtin.c5
-rw-r--r--Test/D07multibyte.ztst4
3 files changed, 12 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 89366f7ec..d666a73bb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2016-10-19  Peter Stephenson  <p.stephenson@samsung.com>
+
+	* 39678: Src/builtin.c, Test/D07multibyte.ztst: printf %q
+	argument needs metafying and result unmetafying.
+
 2016-10-18  m0viefreak  <m0viefreak.cm@googlemail.com>
 
 	* 39590: Src/Zle/compresult.c: zle: Call zle-line-pre-redraw
diff --git a/Src/builtin.c b/Src/builtin.c
index 8b8b217d8..2db739ffc 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -4874,9 +4874,10 @@ bin_print(char *name, char **args, Options ops, int func)
 		break;
 	    case 'q':
 		stringval = curarg ?
-		    quotestring(curarg, QT_BACKSLASH_SHOWNULL) : &nullstr;
+		    quotestring(metafy(curarg, curlen, META_USEHEAP),
+				QT_BACKSLASH_SHOWNULL) : &nullstr;
 		*d = 's';
-		print_val(stringval);
+		print_val(unmetafy(stringval, &curlen));
 		break;
 	    case 'd':
 	    case 'i':
diff --git a/Test/D07multibyte.ztst b/Test/D07multibyte.ztst
index 1b1d042a8..3a6e95543 100644
--- a/Test/D07multibyte.ztst
+++ b/Test/D07multibyte.ztst
@@ -579,3 +579,7 @@
 0:Sorting of metafied Polish characters
 >a ą b c ć d e ę f
 >a ą b c ć d e ę f
+
+  printf '%q%q\n' 你你
+0:printf %q and quotestring and general metafy / token madness
+>你你