aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/rc
diff options
context:
space:
mode:
authorRuss Cox <rsc@swtch.com>2008-08-14 10:29:29 -0400
committerRuss Cox <rsc@swtch.com>2008-08-14 10:29:29 -0400
commit362264eb516483d6e2f45ba1e0ab6bcaf2d4f0ee (patch)
tree902303370b73e9e85cbca969ecf8cc5e466f79ea /src/cmd/rc
parent0e430b25b21cb9e08ccb46c7c5202cd10c13e1dd (diff)
downloadplan9port-362264eb516483d6e2f45ba1e0ab6bcaf2d4f0ee.tar.gz
plan9port-362264eb516483d6e2f45ba1e0ab6bcaf2d4f0ee.tar.bz2
plan9port-362264eb516483d6e2f45ba1e0ab6bcaf2d4f0ee.zip
rc: fix local variables in functions
reported by micah stetson: fn foo { echo $bar } bar=baz foo
Diffstat (limited to 'src/cmd/rc')
-rw-r--r--src/cmd/rc/code.c6
-rw-r--r--src/cmd/rc/simple.c2
2 files changed, 4 insertions, 4 deletions
diff --git a/src/cmd/rc/code.c b/src/cmd/rc/code.c
index 2c33e804..eeaa3ed8 100644
--- 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
index 15814c5c..d587227a 100644
--- 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;