ast_comparator/test/student_data/handout/shlab-handout/cases/reference_9_tsh.c
/////////////////////////////////////////////////////////////////////////////
//
// builtin_cmd - If the user has typed a built-in command then execute
// it immediately. The command name would be in argv[0] and
// is a C string. We've cast this to a C++ string type to simplify
// string comparisons; however, the do_bgfg routine will need 
// to use the argv array as well to look for a job number.
//
If the user has typed a built-in command then execute
it immediately. The command name would be in argv[0] and
is a C string. We've cast this to a C++ string type to simplify
string comparisons; however, the do_bgfg routine will need
to use the argv array as well to look for a job number.
If the user has typed a built - in command then execute it immediately . The command name would be in argv [ 0 ] and is a C string . We ' ve cast this to a C ++ string type to simplify string comparisons ; however the do_bgfg routine will need to use the argv array as well to look for a job number .
int builtin_cmd(char **argv) 
{
  string input(argv[0]); 
  if (input == "quit"){ 
    exit(0);
    }       
  else if((strcmp(argv[0],"bg")) == 0 || (strcmp(argv[0],"fg") == 0)){
    do_bgfg(argv);
    return 1;
  }
  else if (input == "jobs"){
    listjobs(jobs); 
    return 1;
    }               
  return 0;      
}
int builtin_cmd ( char * * argv ) { string input ( argv [ 0 ] ) ; if ( input == " " ) { exit ( 0 ) ; } else if ( ( strcmp ( argv [ 0 ] , " " ) ) == 0 || ( strcmp ( argv [ 0 ] , " " ) == 0 ) ) { do_bgfg ( argv ) ; return 1 ; } else if ( input == " " ) { listjobs ( jobs ) ; return 1 ; } return 0 ; }
builtin_cmd - If the user has typed a built-in command then execute
it immediately.
builtin_cmd - If the user has typed a built - in command then execute it immediately .
//same cmd as used in do_bgfg, will make it so we dont have to strcmpr for every if statement /*quit command*/ //call list jobs function from jobs.cc /* not a builtin command */ /*If builtin_cmd returns 0, the shell creates a child process and executres the requested program inside the child. */