-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
40 lines (32 loc) · 934 Bytes
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include "general.h"
/*
ps -a | grep o | grep gsd | cut -b 1-5
ps aux | grep root | cut -b 1-10
cat scores | grep Villanova | cut -b 1-10
ls -a | grep e
*/
int main() {
string line;
while (true) {
string commands[MAX_COMMAND][MAX_ARGUMET];
// Prompt user to enter commands
printf("Shell -> ");
getline(cin, line);
// Quit shell program if these inputs given
if (line == "exit" || cin.eof()){
cout << endl;
exit(1);
// If enter pressed, don't pass for execution
}else if(line == "\0"){
continue;
}
// Parse all commands seperated by pipes
int commandNr = parseCommands(commands, line);
// Convert types and prepare for execuction
char *all_args[MAX_COMMAND][MAX_ARGUMET];
convertTypesForExecution(commands, all_args);
// Execute commands
executeCommand(commandNr, all_args);
}
return 1;
}