#include #include #include #include #include #include #include #include #include #include #include #include #include "all.h" #include "test.h" using namespace std; using namespace ov4; /* Global variables */ char sbuf[MAXLINE]; /* for composing sprintf messages */ /* * main - The shell's main routine */ int main([[maybe_unused]] int argc, [[maybe_unused]] char **argv) { init(); //test(argv); char cmdline[MAXLINE]; /* Redirect stderr to stdout (so that driver will get all output * on the pipe connected to stdout) */ dup2(1, 2); /* Parse the command line */ exe_option(argv); // while ((c = getopt(argc, argv, "hvp")) != EOF) { // switch (c) { // case 'h': /* print help message */ // usage(); // break; // case 'v': /* emit additional diagnostic info */ // verbose = true; // break; // case 'p': /* don't print a prompt */ // emit_prompt = 0; /* handy for automatic testing */ // break; // default: // usage(); // } // } /* Initialize the job list */ initjobs(); /* Execute the shell's read/eval loop */ while (1) { /* Read command line */ print_prompt(); if ((fgets(cmdline, MAXLINE, stdin) == NULL) && ferror(stdin)) app_error("fgets error"); if (feof(stdin)) { /* End of file (ctrl-d) */ fflush(stdout); exit(0); } /* Evaluate the command line */ // trim \n if(cmdline[strlen(cmdline)-1] == '\n') cmdline[strlen(cmdline)-1] = '\0'; eval(cmdline); fflush(stdout); fflush(stdout); } exit(0); /* control never reaches here */ }