aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2016-10-25 20:26:02 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2016-10-25 20:26:02 +0200
commit7aec86820d7bcf2842d167969c4fa7159ea643f7 (patch)
treea53577353eebe340ba6bc6571944752957b047be
parent20a2cd6291924d405e636916962c6294d3b8544e (diff)
downloadbusybox-w32-7aec86820d7bcf2842d167969c4fa7159ea643f7.tar.gz
busybox-w32-7aec86820d7bcf2842d167969c4fa7159ea643f7.tar.bz2
busybox-w32-7aec86820d7bcf2842d167969c4fa7159ea643f7.zip
ash: [EVAL] Let funcnode refer to a function definition, not its first command
Upstream patch: Date: Tue, 15 Mar 2011 15:44:47 +0800 [EVAL] Let funcnode refer to a function definition, not its first command It is not unrelated: I changed the meaning of struct funcnode's field n to refer to the function definition, rather than the list of the function's commands, because I needed to refer to the function definition node from evalfun, which only gets passed a funcnode. But it is something that could be applied independently (without being useful by itself), so I've attached it as a separate patch for easier review. Signed-off-by: Harald van Dijk <harald@gigawatt.nl> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--shell/ash.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 8092e3971..b7f20ba36 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -8449,14 +8449,14 @@ copyfunc(union node *n)
8449 * Define a shell function. 8449 * Define a shell function.
8450 */ 8450 */
8451static void 8451static void
8452defun(char *name, union node *func) 8452defun(union node *func)
8453{ 8453{
8454 struct cmdentry entry; 8454 struct cmdentry entry;
8455 8455
8456 INT_OFF; 8456 INT_OFF;
8457 entry.cmdtype = CMDFUNCTION; 8457 entry.cmdtype = CMDFUNCTION;
8458 entry.u.func = copyfunc(func); 8458 entry.u.func = copyfunc(func);
8459 addcmdentry(name, &entry); 8459 addcmdentry(func->narg.text, &entry);
8460 INT_ON; 8460 INT_ON;
8461} 8461}
8462 8462
@@ -8654,7 +8654,7 @@ evaltree(union node *n, int flags)
8654 status = 0; 8654 status = 0;
8655 goto setstatus; 8655 goto setstatus;
8656 case NDEFUN: 8656 case NDEFUN:
8657 defun(n->narg.text, n->narg.next); 8657 defun(n);
8658 /* Not necessary. To test it: 8658 /* Not necessary. To test it:
8659 * "false; f() { qwerty; }; echo $?" should print 0. 8659 * "false; f() { qwerty; }; echo $?" should print 0.
8660 */ 8660 */
@@ -9079,7 +9079,7 @@ evalfun(struct funcnode *func, int argc, char **argv, int flags)
9079 shellparam.optind = 1; 9079 shellparam.optind = 1;
9080 shellparam.optoff = -1; 9080 shellparam.optoff = -1;
9081#endif 9081#endif
9082 evaltree(&func->n, flags & EV_TESTED); 9082 evaltree(func->n.narg.next, flags & EV_TESTED);
9083 funcdone: 9083 funcdone:
9084 INT_OFF; 9084 INT_OFF;
9085 funcnest--; 9085 funcnest--;