update README with completed things
This commit is contained in:
parent
260041490f
commit
236db39240
14
Makefile
14
Makefile
|
@ -1,20 +1,20 @@
|
|||
CSW = -O3 -Wall -std=c++11 -ggdb
|
||||
LSW = -lreadline
|
||||
COMPILER_FLAGS = -O3 -Wall -std=c++11 -ggdb
|
||||
LINKER_FLAGS = -lreadline
|
||||
|
||||
all:
|
||||
make bish
|
||||
|
||||
bish: bish.o parse.o util_fns.o Makefile
|
||||
g++ bish.o parse.o util_fns.o -o bish $(LSW)
|
||||
g++ *.o -o bish $(LINKER_FLAGS)
|
||||
|
||||
bish.o: bish.cc Makefile
|
||||
g++ bish.cc -c -o bish.o $(CSW)
|
||||
g++ bish.cc -c -o bish.o $(COMPILER_FLAGS)
|
||||
|
||||
parse.o: parse.cc Makefile
|
||||
g++ parse.cc -c -o parse.o $(CSW)
|
||||
g++ parse.cc -c -o parse.o $(COMPILER_FLAGS)
|
||||
|
||||
util_fns.cc: util_fns.cc Makefile
|
||||
g++ util_fns.cc -c -o util_fns.o $(CSW)
|
||||
g++ util_fns.cc -c -o util_fns.o $(COMPILER_FLAGS)
|
||||
|
||||
clean:
|
||||
touch Makefile; make
|
||||
$(RM) *.o bish; touch Makefile; make
|
||||
|
|
12
README.md
12
README.md
|
@ -17,15 +17,15 @@ The Shell Assignment (total 42 points)
|
|||
+ `/bin/ls`
|
||||
+ 1 ~~You search the path for the executable~~
|
||||
+ `ls`
|
||||
+ 1 Can do file input redirection "<"
|
||||
+ 1 ~~Can do file input redirection "<"~~
|
||||
+ `ls > fred`
|
||||
+ 1 Can do file output redirection ">"
|
||||
+ 1 ~~Can do file output redirection ">"~~
|
||||
+ `ls < fred`
|
||||
+ 2 Can do command piping "|"
|
||||
+ `ls | wc`
|
||||
+ 1 Can do lots of pipes
|
||||
+ `ls | grep fred | wc`
|
||||
+ 1 Can do at least one combination of these things
|
||||
+ 1 ~~Can do at least one combination of these things~~
|
||||
+ `ls | wc > fred`
|
||||
+ 4 Can do any combination of three of <, >, and |
|
||||
+ `cat < filename | sort > sortedFile.txt`
|
||||
|
@ -63,8 +63,8 @@ The Shell Assignment (total 42 points)
|
|||
+ (shell) Did you mean `ls`?
|
||||
+ 2 Can run commands from a file
|
||||
+ `. scriptFile.txt`
|
||||
+ 2 ~~Tab Completion~~ and Arrow History
|
||||
+ 1 Saves and reloads history to a file
|
||||
+ 2 ~~Tab Completion~~ and ~~Arrow History~~
|
||||
+ 1 ~~Saves and reloads history to a file~~
|
||||
+ 2 Automatically runs a file called .myshell when it starts
|
||||
+ 2 Only runs execuatables from an approved list
|
||||
+ -2 Commands cannot have arguments (i.e. ls -l does not work).
|
||||
|
@ -73,7 +73,7 @@ The Shell Assignment (total 42 points)
|
|||
|
||||
Some cases to consider
|
||||
+ A person tries to run a non-executable.
|
||||
+ A person tries to read or write to a non-existant file.
|
||||
+ A person tries to read or write to a non-existent file.
|
||||
+ A person tries to read or write to a file they do not have permissions on.
|
||||
+ A person tries a non-sensical command. (i.e. `ls > foo > fee < doo < dee`)
|
||||
+ A person tries to pipe to a non-command (i.e. `ls | /tmp/foo.txt`)
|
||||
|
|
19
bish.cc
19
bish.cc
|
@ -4,18 +4,14 @@
|
|||
// *************************
|
||||
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <vector>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/types.h>
|
||||
// #include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
#include <sstream>
|
||||
#include <stdio.h>
|
||||
#include <pwd.h>
|
||||
#include <readline/readline.h>
|
||||
#include <readline/history.h>
|
||||
|
@ -42,7 +38,7 @@ int main(int argc, char **argv){
|
|||
using_history();
|
||||
string histpath = string(homedir) + string("/.bish_history");
|
||||
if (read_history(histpath.c_str())) {
|
||||
printf("history file not found. creating `~/.bish_history`.\n");
|
||||
cout << "history file not found. creating `~/.bish_history`." << endl;
|
||||
int hist = open(histpath.c_str(), O_RDWR | O_CREAT, S_IRUSR | S_IRGRP | S_IROTH);
|
||||
close(hist);
|
||||
}
|
||||
|
@ -129,7 +125,7 @@ int main(int argc, char **argv){
|
|||
execv(searchpath.str().c_str(), cmd->args);
|
||||
}
|
||||
// nothing found here...
|
||||
printf("that's not a command, bish\n");
|
||||
cout << "that's not a command, bish" << endl;
|
||||
exit(1);
|
||||
|
||||
}
|
||||
|
@ -145,13 +141,13 @@ int main(int argc, char **argv){
|
|||
exit(1);
|
||||
}
|
||||
if (WIFEXITED(status)) {
|
||||
printf("(%d):", WEXITSTATUS(status));
|
||||
cout << "(" << WEXITSTATUS(status) << "):";
|
||||
} else if (WIFSIGNALED(status)) {
|
||||
printf("\nkilled by signal %d\n", WTERMSIG(status));
|
||||
cout << endl << "killed by signal " << WTERMSIG(status) << endl;
|
||||
} else if (WIFSTOPPED(status)) {
|
||||
printf("\nstopped by signal %d\n", WSTOPSIG(status));
|
||||
cout << endl << "stopped by signal " << WSTOPSIG(status) << endl;
|
||||
} else if (WIFCONTINUED(status)) {
|
||||
printf("\ncontinued\n");
|
||||
cout << endl << "continued" << endl;
|
||||
}
|
||||
} while (!WIFEXITED(status) && !WIFSIGNALED(status));
|
||||
|
||||
|
@ -160,12 +156,11 @@ int main(int argc, char **argv){
|
|||
}
|
||||
|
||||
// reset args array for the next prompt
|
||||
// delete[] args;
|
||||
delete cmd;
|
||||
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
cout << endl;
|
||||
if (write_history(histpath.c_str())) perror("write_history");
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include <vector>
|
||||
#include <string>
|
||||
#include <string.h>
|
||||
#include "util_fns.h"
|
||||
// #include "util_fns.h"
|
||||
using namespace std;
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue