summaryrefslogtreecommitdiff
path: root/sh.c
diff options
context:
space:
mode:
authorrtm <rtm>2006-08-11 13:55:18 +0000
committerrtm <rtm>2006-08-11 13:55:18 +0000
commit17a856577f9db766b8ef7099d0575d378dff5dd1 (patch)
tree53d0c687d9c9bf83d097a2171c48d04a569c5a61 /sh.c
parent5be0039ce9e22f140a29e167526c64c723c5be3c (diff)
downloadxv6-labs-17a856577f9db766b8ef7099d0575d378dff5dd1.tar.gz
xv6-labs-17a856577f9db766b8ef7099d0575d378dff5dd1.tar.bz2
xv6-labs-17a856577f9db766b8ef7099d0575d378dff5dd1.zip
init creates console, opens 0/1/2, runs sh
sh accepts 0-argument commands (like userfs) reads from console
Diffstat (limited to 'sh.c')
-rw-r--r--sh.c31
1 files changed, 31 insertions, 0 deletions
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();
+ }
+}