blob: 0b3dc20b4c6ab8f8f2938e9017f4cccb8236a9ce (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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);
}
}
|