Adjusted a little bit of syntax (personal)

This commit is contained in:
TriantaTV 2022-10-27 23:23:02 -05:00
parent 702b77073f
commit 94f2c4fcb8

View File

@ -123,7 +123,7 @@ void ioRedirection(CommandStruct *command)
void output(char *command){ void output(char *command){
int newfd; int newfd;
if(newfd = open(command, O_CREAT | O_TRUNC | O_WRONLY, 0644)< 0) if (newfd = open(command, O_CREAT | O_TRUNC | O_WRONLY, 0644) < 0)
{ {
perror(command); perror(command);
exit(1); exit(1);
@ -134,7 +134,7 @@ void output(char *command){
void input(char *command) void input(char *command)
{ {
int newfd; int newfd;
if(newfd = open(command, O_RDONLY)<0) if (newfd = open(command, O_RDONLY) < 0)
{ {
perror(command); perror(command);
exit(1); exit(1);
@ -150,57 +150,56 @@ void ExecPipe()
void append(char *input, char *file) void append(char *input, char *file)
{ {
FILE *fp; FILE *fp;
fp = fopen(file, "a+"); fp = fopen(file, "a+");
fputs(input, fp); fputs(input, fp);
fclose(fp); fclose(fp);
} }
// check command standard input
// if (strchr(inputString, '<') != NULL)
// {
// newfd = open((command, O_CREAT |O_TRUNC | O_WRONLY, 0644)) < 0);
// // No if statement for fail checking, brackets just exist here
// {
// // failed
// perror(command);
// exit(1);
// }
// dup2(newfd, 0);
// }
// check pipe // check command standard input
// TODO: Check for pipe symbol // if (strchr(inputString, '<') != NULL)
// Check in command->argv[] instead // {
// if (strchr(command, '|') != NULL) // newfd = open((command, O_CREAT |O_TRUNC | O_WRONLY, 0644)) < 0);
// { // // No if statement for fail checking, brackets just exist here
// ; // {
// } // // failed
// check append // perror(command);
// TODO: Implement append // exit(1);
// if (strpbrk(command, ">>") != NULL) // }
// { // dup2(newfd, 0);
// newfd = open((command, O_CREAT |O_TRUNC | O_WRONLY, 0644)) < 0); // }
// // No if statement for fail checking, brackets just exist here
// { // check pipe
// // failed // TODO: Check for pipe symbol
// perror(command); // Check in command->argv[] instead
// exit(1); // if (strchr(command, '|') != NULL)
// } // {
// dup2(newfd, 0); // ;
// } // }
// check pipe // check append
// TODO: Check pipe already exists above, maybe loop? // TODO: Implement append
// if (strchr(command, '|') != NULL) // if (strpbrk(command, ">>") != NULL)
// { // {
// ; // newfd = open((command, O_CREAT |O_TRUNC | O_WRONLY, 0644)) < 0);
// } // // No if statement for fail checking, brackets just exist here
// check append // {
// TODO: Check append already exists above, maybe loop? // // failed
// if (strpbrk(command, ">>") != NULL) // perror(command);
// { // exit(1);
// ; // }
// } // dup2(newfd, 0);
// }
// check pipe
// TODO: Check pipe already exists above, maybe loop?
// if (strchr(command, '|') != NULL)
// {
// ;
// }
// check append
// TODO: Check append already exists above, maybe loop?
// if (strpbrk(command, ">>") != NULL)
// {
// ;
// }
// Environment varibles // Environment varibles
// TODO: Add this function to CommandStruct // TODO: Add this function to CommandStruct