about summary refs log tree commit diff
path: root/Src/subst.c
diff options
context:
space:
mode:
authorBart Schaefer <barts@users.sourceforge.net>2002-01-06 01:09:09 +0000
committerBart Schaefer <barts@users.sourceforge.net>2002-01-06 01:09:09 +0000
commit0524ab98ff4328f1e9a5e09a66e94523f6a3d903 (patch)
tree3a2d5df6b60a4298c99fe968e9e625ef821f01f8 /Src/subst.c
parent31634c24e7d8bdaa082a1d45560b5feae568d153 (diff)
downloadzsh-0524ab98ff4328f1e9a5e09a66e94523f6a3d903.tar.gz
zsh-0524ab98ff4328f1e9a5e09a66e94523f6a3d903.tar.xz
zsh-0524ab98ff4328f1e9a5e09a66e94523f6a3d903.zip
16400, 16401: preserve empty words that result from brace expansion.
Diffstat (limited to 'Src/subst.c')
-rw-r--r--Src/subst.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/Src/subst.c b/Src/subst.c
index 14ad37386..607e9b979 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -49,8 +49,8 @@ char nulstring[] = {Nularg, '\0'};
 mod_export void
 prefork(LinkList list, int flags)
 {
-    LinkNode node;
-    int asssub = (flags & PF_TYPESET) && isset(KSHTYPESET);
+    LinkNode node, stop = 0;
+    int keep = 0, asssub = (flags & PF_TYPESET) && isset(KSHTYPESET);
 
     queue_signals();
     for (node = firstnode(list); node; incnode(node)) {
@@ -78,15 +78,22 @@ prefork(LinkList list, int flags)
 	}
     }
     for (node = firstnode(list); node; incnode(node)) {
+	if (node == stop)
+	    keep = 0;
 	if (*(char *)getdata(node)) {
 	    remnulargs(getdata(node));
-	    if (unset(IGNOREBRACES) && !(flags & PF_SINGLE))
-		while (hasbraces(getdata(node)))
+	    if (unset(IGNOREBRACES) && !(flags & PF_SINGLE)) {
+		if (!keep)
+		    stop = nextnode(node);
+		while (hasbraces(getdata(node))) {
+		    keep = 1;
 		    xpandbraces(list, &node);
+		}
+	    }
 	    if (unset(SHFILEEXPANSION))
 		filesub((char **)getaddrdata(node),
 			flags & (PF_TYPESET|PF_ASSIGN));
-	} else if (!(flags & PF_SINGLE))
+	} else if (!(flags & PF_SINGLE) && !keep)
 	    uremnode(list, node);
 	if (errflag) {
 	    unqueue_signals();