diff --git a/src/Pish.c b/src/Pish.c index e2cb4d1..45a0104 100644 --- a/src/Pish.c +++ b/src/Pish.c @@ -6,6 +6,32 @@ #include "Integrated.h" #include "Pish.h" +//checks if there is a special symbol for redirection +int redirectCheck(char* command) +{ + int check; + if(strchr(str, '|') != NULL){ + check = 1; + } + else if (strpbrk(str, ">>") != NULL){ + check = 2; + } + else if (strchr(str, '>') != NULL){ + check = 3; + } + else if (strchr(str, '<') != NULL){ + check = 4; + } + else{ + check = 0; +} +//i/o Redirection (void my need to be changed) +void ioRedirect(int sym, char* command) +{ + // |1, >>2, >3, <4 + +} + // Prints a prompt and then reads a command from the terminal char* getInput(void) { @@ -29,18 +55,29 @@ void Pish(void) { char* command; int retval; + int redirect; + while (1) { command = getInput(); //Parse command - char* token = strtok(command, " "); - while(token != NULL) + // Need to check for |,<,>,>> + //redirect = redirectCheck(command); + if (redirect > 0) { - //This only holds 1 command at a time then it overrides - //Will need modified - token = strtok(NULL, " "); + //ioRedirect(redirect, command); } - + else + { + char* token = strtok(command, " "); + while(token != NULL) + { + //This only holds 1 command at a time then it overrides + //Will need modified + token = strtok(NULL, " "); + } + { + IntegratedCheck(command); retval = fork(); // Child