void execute_command (command_t c) { switch(c->type) { case SIMPLE_COMMAND: execute_simple(c); break; case AND_COMMAND: execute_and_command(c); break; case OR_COMMAND: execute_or_command(c); break; case PIPE_COMMAND: execute_pipe_command(c); break; case SUBSHELL_COMMAND: execute_subshell_command(c); break; case SEQUENCE_COMMAND: execute_sequence_command(c); break; default: error(1, 0, "Invalid command type"); } }
void execute_command (command_t c, int time_travel) { /* FIXME: Replace this with your implementation. You may need to add auxiliary functions and otherwise modify the source code. You can also use external functions defined in the GNU C Library. */ if(c == NULL) return; if(time_travel ==1) execute_time_travel(c); else { switch(c->type) { case SIMPLE_COMMAND: execute_simple_command(c); break; case AND_COMMAND: execute_and_command(c); break; case OR_COMMAND: execute_or_command(c); break; case PIPE_COMMAND: execute_pipe_command(c); break; case SUBSHELL_COMMAND: execute_subshell_command(c); break; case SEQUENCE_COMMAND: execute_sequence_command(c); break; case WHILE_COMMAND: execute_while_command(c); break; case FOR_COMMAND: execute_for_command(c); break; case UNTIL_COMMAND: execute_until_command(c); break; case IF_COMMAND: execute_if_command(c); break; case NOT_COMMAND: execute_not_command(c); break; default: error(1,0, "Error: Unknown command!"); break; } //error (1, 0, "command execution not yet implemented"); } }
void execute_wrapper(command_t c) { switch(c->type){ case (SIMPLE_COMMAND): execute_simple_command(c); break; case (AND_COMMAND): case (OR_COMMAND): execute_and_or_command(c); break; case (SEQUENCE_COMMAND): execute_sequence_command(c); break; case (PIPE_COMMAND): execute_pipe_command(c); break; case (SUBSHELL_COMMAND): execute_subshell_command(c); break; } }
void execute_command (command_t c, int time_travel) { /* FIXME: Replace this with your implementation. You may need to add auxiliary functions and otherwise modify the source code. You can also use external functions defined in the GNU C Library. */ if(c == NULL) return; //printf("Enter%d\n", c->type); if (!time_travel) { switch(c->type) { case SIMPLE_COMMAND: execute_simple_command(c); break; case AND_COMMAND: execute_and_command(c); break; case OR_COMMAND: execute_or_command(c); break; case PIPE_COMMAND: execute_pipe_command(c); break; case SEQUENCE_COMMAND: execute_sequence_command(c); break; case SUBSHELL_COMMAND: execute_subshell_command(c); break; default: error(1, 0, "Incorrect Command Type"); } } }