summaryrefslogtreecommitdiff
path: root/Src/subst.c
diff options
context:
space:
mode:
Diffstat (limited to 'Src/subst.c')
-rw-r--r--Src/subst.c39
1 files changed, 23 insertions, 16 deletions
diff --git a/Src/subst.c b/Src/subst.c
index 8c290cccf..d027e3d83 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -108,7 +108,6 @@ prefork(LinkList list, int flags, int *ret_flags)
queue_signals();
node = firstnode(list);
while (node) {
- LinkNode nextnode = 0;
if ((flags & (PREFORK_SINGLE|PREFORK_ASSIGN)) == PREFORK_ASSIGN &&
(insnode = keyvalpairelement(list, node))) {
node = insnode;
@@ -137,23 +136,31 @@ prefork(LinkList list, int flags, int *ret_flags)
* testing if cptr changed...
*/
setdata(node, cptr);
- /*
- * Advance now because we must not expand filenames again
- * after string substitution (which may insert new nodes).
- */
- nextnode = node;
- incnode(nextnode);
- }
- if (!(node = stringsubst(list, node,
- flags & ~(PREFORK_TYPESET|PREFORK_ASSIGN),
- ret_flags, asssub))) {
- unqueue_signals();
- return;
}
- if (isset(SHFILEEXPANSION))
- node = nextnode;
else
- incnode(node);
+ {
+ if (!(node = stringsubst(list, node,
+ flags & ~(PREFORK_TYPESET|PREFORK_ASSIGN),
+ ret_flags, asssub))) {
+ unqueue_signals();
+ return;
+ }
+ }
+ incnode(node);
+ }
+ if (isset(SHFILEEXPANSION)) {
+ /*
+ * stringsubst() may insert new nodes, so doesn't work
+ * well in the same loop as file expansion.
+ */
+ for (node = firstnode(list); node; incnode(node)) {
+ if (!(node = stringsubst(list, node,
+ flags & ~(PREFORK_TYPESET|PREFORK_ASSIGN),
+ ret_flags, asssub))) {
+ unqueue_signals();
+ return;
+ }
+ }
}
for (node = firstnode(list); node; incnode(node)) {
if (node == stop)