handle EOF in shell
This commit is contained in:
parent
349ee132f0
commit
f8f7fcbebd
1 changed files with 5 additions and 2 deletions
7
sh.c
7
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
|
||||
|
|
Loading…
Reference in a new issue