summaryrefslogtreecommitdiff
path: root/sh.c
diff options
context:
space:
mode:
authorrsc <rsc>2007-08-08 08:39:07 +0000
committerrsc <rsc>2007-08-08 08:39:07 +0000
commitf8f7fcbebdae7d3c8ac697373d0769d1ccfc31ae (patch)
tree4a646fc74d28e6fd5376737cdbd54995b35bbb1a /sh.c
parent349ee132f0c7060ad04c5667da24d8cb40654be8 (diff)
downloadxv6-labs-f8f7fcbebdae7d3c8ac697373d0769d1ccfc31ae.tar.gz
xv6-labs-f8f7fcbebdae7d3c8ac697373d0769d1ccfc31ae.tar.bz2
xv6-labs-f8f7fcbebdae7d3c8ac697373d0769d1ccfc31ae.zip
handle EOF in shell
Diffstat (limited to 'sh.c')
-rw-r--r--sh.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/sh.c b/sh.c
index 4a43b27..e74fa72 100644
--- a/sh.c
+++ b/sh.c
@@ -42,12 +42,15 @@ main(void)
{
while(1){
puts("$ ");
- memset(buf, '\0', sizeof(buf));
- gets(buf, sizeof(buf));
+ memset(buf, 0, sizeof buf);
+ gets(buf, sizeof buf);
+ if(buf[0] == 0) // EOF
+ break;
if(parse(buf) < 0)
continue;
runcmd();
}
+ exit();
}
int