Commit Diff


commit - 652f7308666a765b402ca05df725c6fc9f7600c9
commit + 29c35556d62138507ec4e35fd843840a93a7a63d
blob - fc0157940eceda9cf5192e1a537691ab3da52c63
blob + 9066353fc90fc1e205e82451499f657fa58c84a4
--- script.c
+++ script.c
@@ -780,7 +780,7 @@ eval(struct op *op)
 {
 	struct value	 a, b;
 	struct proc	*proc;
-	struct op	*t;
+	struct op	*t, *tnext;
 	int		 i, ret;
 
 #if DEBUG
@@ -866,8 +866,20 @@ eval(struct op *op)
 					break;
 				}
 
-				if ((ret = setvar(proc->args[i], t))
-				    != EVAL_OK)
+				/*
+				 * The arguments are a linked list of
+				 * ops.  Setvar will call eval that
+				 * will evaluate *all* the arguments.
+				 * The dance here that sets next to
+				 * NULL and then restores it is to
+				 * avoid this behaviour.
+				 */
+				tnext = t->next;
+				t->next = NULL;
+				ret = setvar(proc->args[i], t);
+				t->next = tnext;
+
+				if (ret != EVAL_OK)
 					return ret;
 			}