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

PATCH: test ${(q+)...}



Plus an extra dupstring() on the basis that it's better if it doesn't
crash.

pws

diff --git a/Src/utils.c b/Src/utils.c
index 1554fa0..6d0f88d 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -5940,7 +5940,7 @@ quotedzputs(char const *s, FILE *stream)
     /* check for empty string */
     if(!*s) {
 	if (!stream)
-	    return "''";
+	    return dupstring("''");
 	fputs("''", stream);
 	return NULL;
     }
diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst
index 1460ff6..bcea980 100644
--- a/Test/D04parameter.ztst
+++ b/Test/D04parameter.ztst
@@ -1866,3 +1866,17 @@
 >0
 >1 /somewhere
 >2 /random /value
+
+  print -r -- ${(q+):-}
+  print -r -- ${(q+)IFS}
+  print -r -- ${(q+):-oneword}
+  print -r -- ${(q+):-two words}
+  print -r -- ${(q+):-three so-called \'words\'}
+  (setopt rcquotes; print -r -- ${(q+):-three so-called \'words\'})
+0:${(q+)...}
+>''
+>$' \t\n\C-@'
+>oneword
+>'two words'
+>'three so-called '\''words'\'
+>'three so-called ''words'''
diff --git a/Test/D07multibyte.ztst b/Test/D07multibyte.ztst
index f95c06d..39ba5ef 100644
--- a/Test/D07multibyte.ztst
+++ b/Test/D07multibyte.ztst
@@ -546,3 +546,10 @@
   [[ $'\xe3\x83\x9b' != [[:INCOMPLETE:][:INVALID:]] ]] || print fail 3
   [[ $'\xe3\x83\x9b' = ? ]] || print fail 4
 0:Testing incomplete and invalid multibyte character components
+
+  print -r -- ${(q+):-ホ}
+  foo='She said "ホ".  I said "You can'\''t '\''ホ'\'' me!'
+  print -r -- ${(q+)foo}
+0:${(q+)...} with printable multibyte characters
+>ホ
+>'She said "ホ".  I said "You can'\''t '\''ホ'\'' me!'



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