From a4162a2eb31818cee724d71a5feb0b15f795f903 Mon Sep 17 00:00:00 2001 From: Bob Nystrom Date: Tue, 21 Jan 2014 15:41:07 -0800 Subject: [PATCH] Fix #6. Handle Ctrl-D in REPL. --- src/main.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main.c b/src/main.c index 6b20afcd..478b55e3 100644 --- a/src/main.c +++ b/src/main.c @@ -69,6 +69,13 @@ static int runRepl(WrenVM* vm) char line[MAX_LINE]; fgets(line, MAX_LINE, stdin); + // If stdin was closed (usually meaning the used entered Ctrl-D), exit. + if (feof(stdin)) + { + printf("\n"); + return 0; + } + // TODO: Handle failure. wrenInterpret(vm, "(repl)", line); // TODO: Figure out how this should work with wren API.