project-Rushilwiz/main.c
github-classroom[bot] 01aaa805d1
Initial commit
2024-04-23 00:41:56 +00:00

30 lines
758 B
C

// Do not edit this file
/**
* Usage (after running make): ./main
* This file takes input from stdin and outputs to stdout. No CLI args
*/
#include "shell.h"
int main(int argc, char** argv) {
char shell_cmd[MAX_LINE_SIZE + 1];
command_t command;
while (true) {
printf("%s", SHELL_PROMPT);
fgets(shell_cmd, MAX_LINE_SIZE, stdin);
shell_cmd[strcspn(shell_cmd, "\n")] =
'\0'; // remove newline from user input
parse(shell_cmd, &command);
if (command.argc > 0) {
if (execute(&command) == ERROR) {
fprintf(stderr, "%s command failed\n", shell_cmd);
}
}
cleanup(&command);
}
return EXIT_SUCCESS;
}