about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@zsh.org>2016-03-07 09:44:54 +0000
committerPeter Stephenson <pws@zsh.org>2016-03-07 09:44:54 +0000
commitdc2397f7548632910267f31bc1c97d45602453c0 (patch)
tree6300eaa8112875aefb4570d169daa9b62d5c4e28
parent17fb014dc7984902a6697c6412b0cca55300542b (diff)
downloadzsh-dc2397f7548632910267f31bc1c97d45602453c0.tar.gz
zsh-dc2397f7548632910267f31bc1c97d45602453c0.tar.xz
zsh-dc2397f7548632910267f31bc1c97d45602453c0.zip
users/21352: ensure $'' doesn't get elided.
Assign nulstring to it if empty.  Test for all forms of quotation
marks.
-rw-r--r--ChangeLog3
-rw-r--r--Src/subst.c6
-rw-r--r--Test/A03quoting.ztst4
3 files changed, 12 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 52299a364..4db9df49b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2016-03-07  Peter Stephenson  <p.stephenson@samsung.com>
 
+	* users/21352: Src/subst.c, Test/A03quoting.ztst: use nulstring
+	to ensure $'' isn't elided.
+
 	* 38094: Src/signals.c, Test/C03traps.ztst: POSIX exit traps
 	aren't local so local level should be 0 so they don't
 	get trashed if defined in a function.
diff --git a/Src/subst.c b/Src/subst.c
index bb1dd8939..f2d0f6553 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -145,8 +145,12 @@ stringsubstquote(char *strstart, char **pstrdpos)
 	    strret = dyncat(strstart, strsub);
     } else if (strdpos[len])
 	strret = dyncat(strsub, strdpos + len);
-    else
+    else if (*strsub)
 	strret = strsub;
+    else {
+	/* This ensures a $'' doesn't get elided. */
+	strret = dupstring(nulstring);
+    }
 
     *pstrdpos = strret + (strdpos - strstart) + strlen(strsub);
 
diff --git a/Test/A03quoting.ztst b/Test/A03quoting.ztst
index 0cf0e8a02..da3ce359a 100644
--- a/Test/A03quoting.ztst
+++ b/Test/A03quoting.ztst
@@ -74,3 +74,7 @@
 >16#61
 >16#62
 >16#64
+
+ () { print $# } '' "" $''
+0:$'' should not be elided, in common with other empty quotes
+>3