From: Peter Stephenson <p.stephenson@samsung.com>
To: Zsh Hackers' List <zsh-workers@zsh.org>
Subject: PATCH: test ${(q+)...}
Date: Tue, 08 Dec 2015 15:03:15 +0000 [thread overview]
Message-ID: <20151208150315.2bbb23e3@pwslap01u.europe.root.pri> (raw)
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!'
reply other threads:[~2015-12-08 15:03 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20151208150315.2bbb23e3@pwslap01u.europe.root.pri \
--to=p.stephenson@samsung.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).