Skip to content

Commit

Permalink
handle EOF in shell
Browse files Browse the repository at this point in the history
  • Loading branch information
rsc committed Aug 8, 2007
1 parent 349ee13 commit f8f7fcb
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions sh.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f8f7fcb

Please sign in to comment.