test 4 working+ test scripts nearly setup for tracking
This commit is contained in:
@@ -21,12 +21,22 @@ void remove_newline(char*);
|
||||
void exit_branch(const char*);
|
||||
int builtin_response(char*);
|
||||
|
||||
|
||||
int main(void) {
|
||||
int main(int argc, char** argv) {
|
||||
FILE* file = NULL;
|
||||
if(argc == 2) {
|
||||
file = fopen(argv[1], "r");
|
||||
}
|
||||
char buffer[MAX_BUF];
|
||||
while(1) {
|
||||
printf("%s", PROMPT);
|
||||
fgets(buffer, MAX_BUF, stdin);
|
||||
// determine if we're reading from stdin or a stream of some sort
|
||||
if(file == NULL && isatty(STDIN_FILENO)) {
|
||||
printf("%s", PROMPT);
|
||||
fgets(buffer, MAX_BUF, stdin);
|
||||
}
|
||||
else {
|
||||
fgets(buffer, MAX_BUF, file);
|
||||
}
|
||||
|
||||
// Deal with EOF input
|
||||
if(!strlen(buffer)) {
|
||||
exit(0);
|
||||
@@ -109,3 +119,4 @@ int builtin_response(char* buffer) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user