Skip to content

Commit d7ed3a4

Browse files
committed
Exit from interactive mode if input stream is bad
Allow exiting the interactive prompt also with CTRL-D on Unix and CTRL-Z on Windows.
1 parent 58e6c9f commit d7ed3a4

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

main.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,10 @@ int main(int argc, char ** argv) {
475475
std::string line;
476476
bool another_line = true;
477477
do {
478-
std::getline(std::cin, line);
478+
if (!std::getline(std::cin, line)) {
479+
// input stream is bad or EOF received
480+
return 0;
481+
}
479482
if (line.empty() || line.back() != '\\') {
480483
another_line = false;
481484
} else {

0 commit comments

Comments
 (0)