|
@@ -180,15 +180,12 @@ void EShRunLoop() {
|
|
|
}
|
|
|
|
|
|
EShAddCommandToHistory(command);
|
|
|
- int pid = fork();
|
|
|
- if (pid == 0) {
|
|
|
- execlp(command, command, NULL);
|
|
|
- printf("Esh: run command %s failed.\n", command);
|
|
|
- exit(1); // execlp failed
|
|
|
- } else {
|
|
|
- waitpid(pid, NULL, 0);
|
|
|
- printf("\n");
|
|
|
- }
|
|
|
+
|
|
|
+ EShJob* jobs;
|
|
|
+ int jobs_num;
|
|
|
+
|
|
|
+ EShParseCommandIntoJobs(command, &jobs, &jobs_num);
|
|
|
+ EShExecuteJobs(jobs_num, jobs);
|
|
|
}
|
|
|
|
|
|
/* restore the original terminal attributes */
|
|
@@ -200,12 +197,14 @@ void EShShowMsg() {
|
|
|
printf("%s", esh_info_global->invite_message);
|
|
|
}
|
|
|
|
|
|
-void EShParseCommandIntoJobs(char* command) {
|
|
|
+void EShParseCommandIntoJobs(char* command, EShJob** jobs_ptr, int* jobs_num_ptr) {
|
|
|
|
|
|
}
|
|
|
|
|
|
void EShExecuteJobs(int jobs_num, EShJob* jobs_list) {
|
|
|
-
|
|
|
+ for (int i = 0; i < jobs_num; ++i) {
|
|
|
+ EShRunJob(jobs_list[i]);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void EShSetJobCommandType(EShJob* job) {
|
|
@@ -213,7 +212,17 @@ void EShSetJobCommandType(EShJob* job) {
|
|
|
}
|
|
|
|
|
|
void EShRunJob(EShJob* job) {
|
|
|
-
|
|
|
+ // TODO: PIPES INIT & BG PROCESS SUPPORT
|
|
|
+
|
|
|
+ int pid = fork();
|
|
|
+ if (pid == 0) {
|
|
|
+ execvp(job->command[0], job->command);
|
|
|
+ printf("Esh: run command %s failed.\n", job->command);
|
|
|
+ exit(1); // execlp failed
|
|
|
+ } else {
|
|
|
+ waitpid(pid, NULL, 0);
|
|
|
+ printf("\n");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
int EmptyCommand(const char* command) {
|