update README with latest points

This commit is contained in:
Ben Harris 2016-11-10 17:07:47 -05:00
parent 0b9b3a9341
commit e32250ec1c
3 changed files with 8 additions and 23 deletions

View File

@ -52,7 +52,7 @@ The Shell Assignment (total 42 points)
+ 1 Concatenate commands with &. Only runs next command if the previous
comand returned success.
+ `cd /home/rappleto & rm fred.txt`
+ 1 Catch Keyboard interrupt
+ 1 ~~Catch Keyboard interrupt~~
+ `ctrl + c` = back to prompt
+ 1 Replace "~" with the home directory
+ `rm ~/junkfile`
@ -69,7 +69,7 @@ The Shell Assignment (total 42 points)
+ 2 Only runs execuatables from an approved list
+ -2 Commands cannot have arguments (i.e. ls -l does not work).
13 pts
14 pts
/20
Some cases to consider

13
bish.cc
View File

@ -57,7 +57,6 @@ int main(int argc, char **argv){
vector<string> wfwe = split(line, ';');
for (auto it: wfwe) {
command *cmd = parse(split(it.c_str()));
// print_cmd(cmd);
// clear line var
@ -67,6 +66,7 @@ int main(int argc, char **argv){
// COMMANDS that do something with the line before fork/exec
if (strcmp(cmd->args[0], "!") == 0) {
line = history_get(where_history())->line;
cout << line << endl;
cmd = parse(split(line));
}
@ -132,7 +132,6 @@ int main(int argc, char **argv){
}
}
// try to run it as is
execv(cmd->args[0], cmd->args);
// search the path
@ -146,7 +145,7 @@ int main(int argc, char **argv){
cout << "that's not a command, bish" << endl;
exit(1);
}
} // end child
// parent waits for kid to die
else {
@ -170,15 +169,15 @@ int main(int argc, char **argv){
} while (!WIFEXITED(status) && !WIFSIGNALED(status));
}
}
} // end parent
}
} // end execute area
// reset args array for the next prompt
delete cmd;
}
}
} // end ';' split
} // end main while loop
cout << endl;
if (write_history(histpath.c_str())) perror("write_history");

View File

@ -1,14 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
#define MAX_LENGTH 1024
int main(int argc, char *argv[]) {
char line[MAX_LENGTH];
while (1) {
printf("simplesh$ ");
if (!fgets(line, MAX_LENGTH, stdin)) break;
system(line);
}
return 0;
}