From 17a856577f9db766b8ef7099d0575d378dff5dd1 Mon Sep 17 00:00:00 2001 From: rtm Date: Fri, 11 Aug 2006 13:55:18 +0000 Subject: init creates console, opens 0/1/2, runs sh sh accepts 0-argument commands (like userfs) reads from console --- sh.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 sh.c (limited to 'sh.c') diff --git a/sh.c b/sh.c new file mode 100644 index 0000000..e9ed2d9 --- /dev/null +++ b/sh.c @@ -0,0 +1,31 @@ +#include "user.h" +#include "types.h" +#include "fs.h" +#include "fcntl.h" + +char *args[100]; + +int +main(void) +{ + char buf[128]; + int pid; + + while(1){ + write(1, "$ ", 2); + gets(buf, sizeof(buf)); + if(buf[0] == '\0') + continue; + pid = fork(); + if(pid == 0){ + args[0] = buf; + args[1] = 0; + exec(buf, args); + write(1, buf, strlen(buf)); + write(1, ": not found\n", 12); + exit(); + } + if(pid > 0) + wait(); + } +} -- cgit v1.2.3