From 9a4c9940d507a9bd52827e2c2d0ee15e3212467c Mon Sep 17 00:00:00 2001 From: Max Bernstein Date: Wed, 8 Feb 2023 14:18:16 -0500 Subject: [PATCH] Allow using Ctrl-D to quit the REPL Without this, `std::getline` fails silently and this loops infinitely printing the prompt. --- src/main.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 97798339..a7fb9dd0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -30,7 +30,9 @@ int main(int argc, char** argv){ while(true){ (*vm->_stdout) << (need_more_lines ? "... " : ">>> "); std::string line; - std::getline(std::cin, line); + if (!std::getline(std::cin, line)) { + break; + } need_more_lines = pkpy_repl_input(repl, line.c_str()); } pkpy_delete(vm);