commit 362264eb516483d6e2f45ba1e0ab6bcaf2d4f0ee
parent 0e430b25b21cb9e08ccb46c7c5202cd10c13e1dd
Author: Russ Cox <rsc@swtch.com>
Date: Thu, 14 Aug 2008 10:29:29 -0400
rc: fix local variables in functions
reported by micah stetson:
fn foo { echo $bar }
bar=baz foo
Diffstat:
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/cmd/rc/code.c b/src/cmd/rc/code.c
@@ -339,9 +339,9 @@ outcode(tree *t, int eflag)
outcode(c0, eflag);
emitf(Xlocal);
}
- t = tt;
- outcode(c2, eflag);
- for(;t->type=='=';t = c2) emitf(Xunlocal);
+ outcode(t, eflag);
+ for(t = tt; t->type=='='; t = c2)
+ emitf(Xunlocal);
}
else{
for(t = tt;t;t = c2){
diff --git a/src/cmd/rc/simple.c b/src/cmd/rc/simple.c
@@ -130,7 +130,7 @@ execfunc(var *func)
starval = runq->argv->words;
runq->argv->words = 0;
poplist();
- start(func->fn, func->pc, (struct var *)0);
+ start(func->fn, func->pc, runq->local);
runq->local = newvar(strdup("*"), runq->local);
runq->local->val = starval;
runq->local->changed = 1;