From da735a2052f64cd53a8b79596946ee187cc58a81 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Tue, 27 Apr 2021 07:10:11 -0500 Subject: Make toysh function return properly and run next statement. --- toys/pending/sh.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/toys/pending/sh.c b/toys/pending/sh.c index 70d7280c..d0e73dc8 100644 --- a/toys/pending/sh.c +++ b/toys/pending/sh.c @@ -2366,6 +2366,7 @@ static struct sh_process *run_command(void) else if (funk != TT.funcslen) { (TT.ff->func = TT.functions[funk])->refcount++; TT.ff->pl = TT.ff->func->pipeline; + TT.ff->next->pl = TT.ff->next->pl->next; TT.ff->arg = pp->arg; } else { struct toy_list *tl = toy_find(*pp->arg.v); @@ -2450,7 +2451,7 @@ static struct sh_pipeline *add_pl(struct sh_pipeline **ppl, struct sh_arg **arg) { struct sh_pipeline *pl = xzalloc(sizeof(struct sh_pipeline)); - *arg = pl->arg; + if (arg) *arg = pl->arg; pl->lineno = TT.LINENO; dlist_add_nomalloc((void *)ppl, (void *)pl); @@ -2557,6 +2558,7 @@ static int parse_line(char *line, struct sh_pipeline **ppl, (*ppl)->prev->next = pl->next; pl->next = *ppl; (*ppl)->prev = pl; + dlist_terminate(funky->pipeline = add_pl(&funky->pipeline, 0)); // Immature function has matured (meaning cleanup is different) pl->type = 'F'; -- cgit v1.2.3