Signed-off-by: Harald van Dijk diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-03-11 Harald van Dijk + + * Let funcnode refer to a function definition, not its first command. + 2011-03-10 Jonathan Nieder * Dotcmd should exit with zero when doing nothing. diff --git a/src/eval.c b/src/eval.c --- a/src/eval.c +++ b/src/eval.c @@ -296,7 +296,7 @@ calleval: } goto success; case NDEFUN: - defun(n->narg.text, n->narg.next); + defun(n); success: status = 0; setstatus: @@ -954,7 +954,7 @@ evalfun(struct funcnode *func, int argc, shellparam.optind = 1; shellparam.optoff = -1; pushlocalvars(); - evaltree(&func->n, flags & EV_TESTED); + evaltree(func->n.narg.next, flags & EV_TESTED); poplocalvars(0); funcdone: INTOFF; diff --git a/src/exec.c b/src/exec.c --- a/src/exec.c +++ b/src/exec.c @@ -688,14 +688,14 @@ addcmdentry(char *name, struct cmdentry */ void -defun(char *name, union node *func) +defun(union node *func) { struct cmdentry entry; INTOFF; entry.cmdtype = CMDFUNCTION; entry.u.func = copyfunc(func); - addcmdentry(name, &entry); + addcmdentry(func->narg.text, &entry); INTON; } diff --git a/src/exec.h b/src/exec.h --- a/src/exec.h +++ b/src/exec.h @@ -71,7 +71,7 @@ void changepath(const char *); #ifdef notdef void getcmdentry(char *, struct cmdentry *); #endif -void defun(char *, union node *); +void defun(union node *); void unsetfunc(const char *); int typecmd(int, char **); int commandcmd(int, char **);