> Is this a bug?
> 
> % fn foo { echo $bar }
> % bar=baz foo
> 
> %
> 
> I would expect to see baz instead of a blank line.

Yes, it is a bug.  The fix is:

diff -r f7e7b9ab4cfb src/cmd/rc/simple.c
--- a/src/cmd/rc/simple.c       Sun Jul 20 06:17:17 2008 -0400
+++ b/src/cmd/rc/simple.c       Thu Aug 14 10:27:08 2008 -0400
@@ -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;

There's also a small performance bug here:

diff -r f7e7b9ab4cfb src/cmd/rc/code.c
--- a/src/cmd/rc/code.c Sun Jul 20 06:17:17 2008 -0400
+++ b/src/cmd/rc/code.c Thu Aug 14 10:27:08 2008 -0400
@@ -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){

Both fixes are in plan9port.

Russ


Reply via email to