1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-24 01:15:07 +00:00

Shell: Treat ^D as builtin_exit when not in a continuation

This commit is contained in:
AnotherTest 2020-05-30 22:35:40 +04:30 committed by Andreas Kling
parent f3b09ddd8e
commit 8c05e78b6c

View file

@ -1719,11 +1719,24 @@ bool Shell::read_single_line()
auto line_result = editor->get_line(prompt());
if (line_result.is_error()) {
m_complete_line_builder.clear();
m_should_continue = ContinuationRequest::Nothing;
m_should_break_current_command = false;
Core::EventLoop::current().quit(line_result.error() == Line::Editor::Error::Eof ? 0 : 1);
return false;
if (line_result.error() == Line::Editor::Error::Eof || line_result.error() == Line::Editor::Error::Empty) {
// Pretend the user tried to execute builtin_exit()
// but only if there's no continuation.
if (m_should_continue == ContinuationRequest::Nothing) {
m_complete_line_builder.clear();
run_command("exit");
return read_single_line();
} else {
// Ignore the Eof.
return true;
}
} else {
m_complete_line_builder.clear();
m_should_continue = ContinuationRequest::Nothing;
m_should_break_current_command = false;
Core::EventLoop::current().quit(1);
return false;
}
}
auto& line = line_result.value();