//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::// //:: shell.c: main file for shell project ::// //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::// static char rcsid[] = "$Id: shell.C,v 1.7 1995/09/28 03:19:18 wilmesj Exp $"; /* $Log: shell.C,v $ * Revision 1.7 1995/09/28 03:19:18 wilmesj * Minor cleanups * * Revision 1.6 1995/09/28 02:06:28 wilmesj * Comments galore. * * Revision 1.5 1995/09/27 17:32:15 wilmesj * *** empty log message *** * * Revision 1.4 1995/09/12 23:12:36 wilmesj * Switched kill sig 0 to wait with W_NOHANG for process checks * * Revision 1.3 1995/09/12 21:43:50 josh * *** empty log message *** * * Revision 1.2 1995/09/10 17:26:26 josh * Main file for shell. * * Revision 1.1 1995/09/08 04:09:49 josh * Initial revision * */ #include #include "shell.h" //::::::::::::::::::::::::::: command_loop() ::::::::::::::::::::::::::::::// /* Function: command_loop() * Purpose: Main I/O loop. Uses readline to get input, calls parser, etc. * Returns: n/a * Uses: lots. */ void command_loop() // Main command input/eval looper. { char* input_line,*restofline,*command=new char[255]; // FIX int cmd; while (1) // loop until a break. { find_exit(); // See if any backgrounded processes have exited. input_line=rl_gets("# "); // Get a line of input (GNU readline) if (!input_line) break; // If they hit ctrl-d (EOF), exit. bzero(command,255); // Wipe out any old commands in the buffer. cmd=parse_line(input_line,command,restofline); switch (cmd) { case MYSH_QUIT: return; case MYSH_HELP: do_help(restofline); break; case MYSH_RUN: run(restofline,NOBG); break; case MYSH_BG: run(restofline,BG); break; case MYSH_PS: ps(); break; case MYSH_KILL: kill_pid(restofline); break; case MYSH_UNKNOWN_COMMAND: printf ("mysh: %s: command not found.\n",command); } } } //::::::::::::::::::::::::::::::: main ::::::::::::::::::::::::::::::// /* Function: main() * Purpose: Pointless main() * Returns: n/a * Uses: n/a */ int main() { signal (SIGINT, SIG_IGN); command_loop(); printf("\n"); }