test 4 working+ test scripts nearly setup for tracking
This commit is contained in:
parent
a85dffe4da
commit
c02a7905b2
3
334/.gitignore
vendored
3
334/.gitignore
vendored
@ -1 +1,4 @@
|
|||||||
bin
|
bin
|
||||||
|
msh
|
||||||
|
*txt
|
||||||
|
*sh
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# Single make file for everything becauz lazy
|
# Single make file for everything becauz lazy
|
||||||
object=homework/msh/msh.c
|
object=homework/msh/msh.c
|
||||||
cc=gcc
|
cc=gcc
|
||||||
output=bin
|
output=msh
|
||||||
|
|
||||||
default:
|
default:
|
||||||
$(cc) $(object) -o $(output)
|
$(cc) $(object) -o $(output)
|
||||||
|
@ -21,12 +21,22 @@ void remove_newline(char*);
|
|||||||
void exit_branch(const char*);
|
void exit_branch(const char*);
|
||||||
int builtin_response(char*);
|
int builtin_response(char*);
|
||||||
|
|
||||||
|
int main(int argc, char** argv) {
|
||||||
int main(void) {
|
FILE* file = NULL;
|
||||||
|
if(argc == 2) {
|
||||||
|
file = fopen(argv[1], "r");
|
||||||
|
}
|
||||||
char buffer[MAX_BUF];
|
char buffer[MAX_BUF];
|
||||||
while(1) {
|
while(1) {
|
||||||
printf("%s", PROMPT);
|
// determine if we're reading from stdin or a stream of some sort
|
||||||
fgets(buffer, MAX_BUF, stdin);
|
if(file == NULL && isatty(STDIN_FILENO)) {
|
||||||
|
printf("%s", PROMPT);
|
||||||
|
fgets(buffer, MAX_BUF, stdin);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fgets(buffer, MAX_BUF, file);
|
||||||
|
}
|
||||||
|
|
||||||
// Deal with EOF input
|
// Deal with EOF input
|
||||||
if(!strlen(buffer)) {
|
if(!strlen(buffer)) {
|
||||||
exit(0);
|
exit(0);
|
||||||
@ -109,3 +119,4 @@ int builtin_response(char* buffer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user