handle EOF in shell

This commit is contained in:
rsc 2007-08-08 08:39:07 +00:00
parent 349ee132f0
commit f8f7fcbebd

7
sh.c
View file

@ -42,12 +42,15 @@ main(void)
{ {
while(1){ while(1){
puts("$ "); puts("$ ");
memset(buf, '\0', sizeof(buf)); memset(buf, 0, sizeof buf);
gets(buf, sizeof(buf)); gets(buf, sizeof buf);
if(buf[0] == 0) // EOF
break;
if(parse(buf) < 0) if(parse(buf) < 0)
continue; continue;
runcmd(); runcmd();
} }
exit();
} }
int int