about summary refs log tree commit diff
diff options
context:
space:
mode:
-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