aboutsummaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2009-04-23 00:31:07 +1000
committerNguyễn Thái Ngọc Duy <pclouds@gmail.com>2009-04-23 04:44:47 +1000
commitba7cf21b047b493600e41c885c87d176b1af2ef5 (patch)
treec9732aa98bfcd00215fa3795eaea8ee553534202 /shell
parent51c840935d442d0fc2aaddb956a010af6841ebb1 (diff)
downloadbusybox-w32-ba7cf21b047b493600e41c885c87d176b1af2ef5.tar.gz
busybox-w32-ba7cf21b047b493600e41c885c87d176b1af2ef5.tar.bz2
busybox-w32-ba7cf21b047b493600e41c885c87d176b1af2ef5.zip
shell/ash: reimplement evalsubshell()
Diffstat (limited to 'shell')
-rw-r--r--shell/ash.c15
-rw-r--r--shell/ash_mingw.c11
2 files changed, 23 insertions, 3 deletions
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)
7766static void 7766static void
7767evalsubshell(union node *n, int flags) 7767evalsubshell(union node *n, int flags)
7768{ 7768{
7769#ifndef __MINGW32__
7769 struct job *jp; 7770 struct job *jp;
7771#endif
7770 int backgnd = (n->type == NBACKGND); 7772 int backgnd = (n->type == NBACKGND);
7771 int status; 7773 int status;
7772 7774
7773 expredir(n->nredir.redirect); 7775 expredir(n->nredir.redirect);
7774 if (!backgnd && flags & EV_EXIT && !trap[0]) 7776 if (!backgnd && flags & EV_EXIT && !trap[0]) {
7775 goto nofork; 7777 redirect(n->nredir.redirect, 0);
7778 evaltreenr(n->nredir.n, flags);
7779 } else {
7780#ifdef __MINGW32__
7781 status = forkshell("evalsubshell", n, backgnd ? (flags | EV_EXIT | EV_TESTED) : (flags | EV_EXIT));
7782 }
7783#else
7776 INT_OFF; 7784 INT_OFF;
7777 jp = makejob(n, 1); 7785 jp = makejob(n, 1);
7778 if (forkshell(jp, n, backgnd) == 0) { 7786 if (forkshell(jp, n, backgnd) == 0) {
@@ -7780,14 +7788,15 @@ evalsubshell(union node *n, int flags)
7780 flags |= EV_EXIT; 7788 flags |= EV_EXIT;
7781 if (backgnd) 7789 if (backgnd)
7782 flags &=~ EV_TESTED; 7790 flags &=~ EV_TESTED;
7783 nofork:
7784 redirect(n->nredir.redirect, 0); 7791 redirect(n->nredir.redirect, 0);
7785 evaltreenr(n->nredir.n, flags); 7792 evaltreenr(n->nredir.n, flags);
7786 /* never returns */ 7793 /* never returns */
7787 } 7794 }
7795 }
7788 status = 0; 7796 status = 0;
7789 if (! backgnd) 7797 if (! backgnd)
7790 status = waitforjob(jp); 7798 status = waitforjob(jp);
7799#endif
7791 exitstatus = status; 7800 exitstatus = status;
7792 INT_ON; 7801 INT_ON;
7793} 7802}
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)
804 eflag = 0; 804 eflag = 0;
805 evaltree(n, EV_EXIT); /* actually evaltreenr... */ 805 evaltree(n, EV_EXIT); /* actually evaltreenr... */
806} 806}
807
808static void
809evalsubshell_fp(union node *n, int flags)
810{
811 trace_printf("ash: subshell: %s\n",__PRETTY_FUNCTION__);
812 INT_ON;
813 expredir(n->nredir.redirect);
814 redirect(n->nredir.redirect, 0);
815 evaltreenr(n->nredir.n, flags);
816}
807/* entry names should not be too long */ 817/* entry names should not be too long */
808struct forkpoint forkpoints[] = { 818struct forkpoint forkpoints[] = {
809 { "evalbackcmd", evalbackcmd_fp }, 819 { "evalbackcmd", evalbackcmd_fp },
820 { "evalsubshell", evalsubshell_fp },
810 { NULL, NULL }, 821 { NULL, NULL },
811}; 822};
812 823