xv6

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit f8f7fcbebdae7d3c8ac697373d0769d1ccfc31ae
parent 349ee132f0c7060ad04c5667da24d8cb40654be8
Author: rsc <rsc>
Date:   Wed,  8 Aug 2007 08:39:07 +0000

handle EOF in shell

Diffstat:
Msh.c | 7+++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git 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