From ba7cf21b047b493600e41c885c87d176b1af2ef5 Mon Sep 17 00:00:00 2001 From: Nguyễn Thái Ngọc Duy Date: Thu, 23 Apr 2009 00:31:07 +1000 Subject: shell/ash: reimplement evalsubshell() --- shell/ash.c | 15 ++++++++++++--- shell/ash_mingw.c | 11 +++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) (limited to 'shell') diff --git a/shell/ash.c b/shell/ash.c index 2d2368bc8..083903486 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -7766,13 +7766,21 @@ evalcase(union node *n, int flags) static void evalsubshell(union node *n, int flags) { +#ifndef __MINGW32__ struct job *jp; +#endif int backgnd = (n->type == NBACKGND); int status; expredir(n->nredir.redirect); - if (!backgnd && flags & EV_EXIT && !trap[0]) - goto nofork; + if (!backgnd && flags & EV_EXIT && !trap[0]) { + redirect(n->nredir.redirect, 0); + evaltreenr(n->nredir.n, flags); + } else { +#ifdef __MINGW32__ + status = forkshell("evalsubshell", n, backgnd ? (flags | EV_EXIT | EV_TESTED) : (flags | EV_EXIT)); + } +#else INT_OFF; jp = makejob(n, 1); if (forkshell(jp, n, backgnd) == 0) { @@ -7780,14 +7788,15 @@ evalsubshell(union node *n, int flags) flags |= EV_EXIT; if (backgnd) flags &=~ EV_TESTED; - nofork: redirect(n->nredir.redirect, 0); evaltreenr(n->nredir.n, flags); /* never returns */ } + } status = 0; if (! backgnd) status = waitforjob(jp); +#endif exitstatus = status; INT_ON; } diff --git a/shell/ash_mingw.c b/shell/ash_mingw.c index 7cf9c8213..d343b2885 100644 --- a/shell/ash_mingw.c +++ b/shell/ash_mingw.c @@ -804,9 +804,20 @@ evalbackcmd_fp(union node *n, int flags) eflag = 0; evaltree(n, EV_EXIT); /* actually evaltreenr... */ } + +static void +evalsubshell_fp(union node *n, int flags) +{ + trace_printf("ash: subshell: %s\n",__PRETTY_FUNCTION__); + INT_ON; + expredir(n->nredir.redirect); + redirect(n->nredir.redirect, 0); + evaltreenr(n->nredir.n, flags); +} /* entry names should not be too long */ struct forkpoint forkpoints[] = { { "evalbackcmd", evalbackcmd_fp }, + { "evalsubshell", evalsubshell_fp }, { NULL, NULL }, }; -- cgit v1.2.3-55-g6feb