我正在尝试创建一个交互式 shell 程序,它提示用户输入命令,解析命令,然后使用子进程执行它。这是我拥有的代码,但我不确定在此 PLEAE HELP 之后该去哪里!!!!
Int shell(char *cmd_str ){
int commandLength=0;
cmd_t command;
commandLength=make_cmd(cmd_str, command);
cout<< commandLength<<endl;
cout << command.argv[0]<< endl;
if( execvp( command.argv[0], command.argv)==-1)
//if the command it executed nothing runs after this line
{
commandLength=-1;
}else
{
cout<<"work"<<endl;
}
cout<< commandLength<<endl;
return commandLength;
}