From bc4ca2a54785b03ee771180d1142496f06f76adb Mon Sep 17 00:00:00 2001 From: Jeremy Huddleston Date: Fri, 14 May 2010 16:59:11 -0700 Subject: Allow quitting via EOF (^D) on the command line Signed-off-by: Jeremy Huddleston --- scope.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'scope.c') diff --git a/scope.c b/scope.c index 94ba173..e33c9d9 100644 --- a/scope.c +++ b/scope.c @@ -335,8 +335,14 @@ ReadCommands (void) here = 1; for (;;) { printf ("> "); - if (!fgets (line, sizeof line, stdin)) - break; + if (!fgets (line, sizeof line, stdin)) { + if(feof(stdin)) { + strlcpy(line, "quit", sizeof(line)); + } else { + printf("Error: %s\n", strerror(errno)); + break; + } + } argc = CMDSplitIntoWords(line, argv); if (argc > 0) { func = CMDStringToFunc (argv[0]); -- cgit v1.2.1