diff options
author | WlodekM <[email protected]> | 2025-02-14 19:12:47 +0200 |
---|---|---|
committer | WlodekM <[email protected]> | 2025-02-14 19:12:47 +0200 |
commit | 3bd3984e92fdfb529c37b31c6f0570abab1ed54e (patch) | |
tree | 5462664b63182c895cb70e98a79672d2c3d8a392 /progs/shel |
initial commit; beginning work on smolsh
Diffstat (limited to 'progs/shel')
-rw-r--r-- | progs/shel/shel.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/progs/shel/shel.c b/progs/shel/shel.c new file mode 100644 index 0000000..f375250 --- /dev/null +++ b/progs/shel/shel.c @@ -0,0 +1,42 @@ +#include <unistd.h> +#include <stdlib.h> +#include <sys/wait.h> +#include <stdbool.h> +#include <string.h> + +void parseInput(char *input, char *command, char *argv) { + bool reachedArgv = false; + char arg[32] = {0}; + int idx = 0; + int argvIdx = 1; + + for (int i = 0; i < sizeof(input); i++) + { + if (reachedArgv) { + arg[idx] = input[i]; + idx++; + continue; + } + if (input[i] == ' ') { + arg[idx] == '\0'; + strcpy(command, arg); + reachedArgv = true; + memset(arg, 0, sizeof(arg)); + idx++; + continue; + } + arg[idx] = input[i]; + idx++; + } + +} + +int main() { + char input[255] = {0}; + char command[128] = {0}; + char *argv[32] = {0}; + char *env[32] = {"PATH=/bin"}; + char path[128] = "/"; + + parseInput(input, command, argv); +} \ No newline at end of file |