diff options
Diffstat (limited to 'sh.c')
-rw-r--r-- | sh.c | 30 |
1 files changed, 23 insertions, 7 deletions
@@ -721,6 +721,7 @@ static int parseCommand(char **commandPtr, struct job *job, int *isBg) | |||
721 | return 0; | 721 | return 0; |
722 | } | 722 | } |
723 | 723 | ||
724 | |||
724 | static int runCommand(struct job newJob, struct jobSet *jobList, int inBg) | 725 | static int runCommand(struct job newJob, struct jobSet *jobList, int inBg) |
725 | { | 726 | { |
726 | struct job *job; | 727 | struct job *job; |
@@ -728,14 +729,10 @@ static int runCommand(struct job newJob, struct jobSet *jobList, int inBg) | |||
728 | int nextin, nextout; | 729 | int nextin, nextout; |
729 | int pipefds[2]; /* pipefd[0] is for reading */ | 730 | int pipefds[2]; /* pipefd[0] is for reading */ |
730 | struct builtInCommand *x; | 731 | struct builtInCommand *x; |
732 | #ifdef BB_FEATURE_STANDALONE_SHELL | ||
733 | const struct BB_applet *a = applets; | ||
734 | #endif | ||
731 | 735 | ||
732 | /* handle built-ins here -- we don't fork() so we can't background | ||
733 | these very easily */ | ||
734 | for (x = bltins; x->cmd; x++) { | ||
735 | if (!strcmp(newJob.progs[0].argv[0], x->cmd)) { | ||
736 | return (x->function(&newJob, jobList)); | ||
737 | } | ||
738 | } | ||
739 | 736 | ||
740 | nextin = 0, nextout = 1; | 737 | nextin = 0, nextout = 1; |
741 | for (i = 0; i < newJob.numProgs; i++) { | 738 | for (i = 0; i < newJob.numProgs; i++) { |
@@ -762,6 +759,25 @@ static int runCommand(struct job newJob, struct jobSet *jobList, int inBg) | |||
762 | /* explicit redirections override pipes */ | 759 | /* explicit redirections override pipes */ |
763 | setupRedirections(newJob.progs + i); | 760 | setupRedirections(newJob.progs + i); |
764 | 761 | ||
762 | /* Match any built-ins here */ | ||
763 | for (x = bltins; x->cmd; x++) { | ||
764 | if (!strcmp(newJob.progs[i].argv[0], x->cmd)) { | ||
765 | exit (x->function(&newJob, jobList)); | ||
766 | } | ||
767 | } | ||
768 | #ifdef BB_FEATURE_STANDALONE_SHELL | ||
769 | /* Handle busybox internals here */ | ||
770 | while (a->name != 0) { | ||
771 | if (strcmp(newJob.progs[i].argv[0], a->name) == 0) { | ||
772 | int argc; | ||
773 | char** argv=newJob.progs[i].argv; | ||
774 | for(argc=0;*argv!=NULL, argv++, argc++); | ||
775 | exit((*(a->main)) (argc, newJob.progs[i].argv)); | ||
776 | } | ||
777 | a++; | ||
778 | } | ||
779 | #endif | ||
780 | |||
765 | execvp(newJob.progs[i].argv[0], newJob.progs[i].argv); | 781 | execvp(newJob.progs[i].argv[0], newJob.progs[i].argv); |
766 | fatalError("sh: %s: %s\n", newJob.progs[i].argv[0], | 782 | fatalError("sh: %s: %s\n", newJob.progs[i].argv[0], |
767 | strerror(errno)); | 783 | strerror(errno)); |