Ejemplo n.º 1
0
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");
    }

}
Ejemplo n.º 2
0
int
execute_command (command_t c, bool a)
{
  if (!a) {
  switch(c->type){
    case AND_COMMAND:
      return execute_and_command(c);
      break;
    case OR_COMMAND:
      return execute_or_command(c);
      break;
    case SEQUENCE_COMMAND:
      return execute_sequence_command(c);
      break;
    case PIPE_COMMAND:
      return execute_pipe_command(c);
      break;
    case SIMPLE_COMMAND:
      return execute_simple_command(c);
      break;
    case SUBSHELL_COMMAND:
      return execute_command(c->u.subshell_command, 0);
      break;
  }
 }
}
Ejemplo n.º 3
0
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");
     }
}
Ejemplo n.º 4
0
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;
        }
}
Ejemplo n.º 5
0
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");
      }
     }
}