Added a redirect checker and started ioredirect function

This commit is contained in:
Samantha Boyer 2022-10-23 20:57:30 -05:00
parent c21e2fb7f6
commit adc4064f08

View File

@ -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