diff options
Diffstat (limited to 'smash/main.c')
| -rw-r--r-- | smash/main.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/smash/main.c b/smash/main.c new file mode 100644 index 0000000..0b3dc20 --- /dev/null +++ b/smash/main.c @@ -0,0 +1,26 @@ +#include "exec.h" + +#include "../lib/sys/io.h" +#include "../lib/cstr/cstr.h" + +#define BUFSIZ 1024 + +void clear_buf(char *buf) +{ + for (int i = 0; i < BUFSIZ; ++i) + buf[i] = 0; +} + +int main(int argc, char *argv[], char *envp[]) +{ + char buf[BUFSIZ] = {0}; + char prompt[] = "$ "; + + while (1) { + write(STDOUT_FD, prompt, cstr_length(prompt)); + read(STDIN_FD, buf, 1024); + buf[cstr_length(buf) - 1] = 0; + exec(buf); + clear_buf(buf); + } +} |