Skip to content

Commit

Permalink
Shell: Exit the shell on (interactive) EOF with empty buffer
Browse files Browse the repository at this point in the history
In other words, if the user presses EOF (normally Ctrl+D), we now print
out "<EOF>" and exit the shell without error.

Fixes SerenityOS#701.
  • Loading branch information
awesomekling committed Nov 1, 2019
1 parent 390b219 commit 845094f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Shell/LineEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,13 @@ String LineEditor::get_line(const String& prompt)
}
continue;
}
if (ch == g.termios.c_cc[VEOF]) { // Normally ^D
if (m_buffer.is_empty()) {
printf("<EOF>\n");
exit(0);
}
continue;
}
if (ch == 0x05) { // ^E
if (m_cursor < m_buffer.size()) {
printf("\033[%dC", m_buffer.size() - m_cursor);
Expand Down

0 comments on commit 845094f

Please sign in to comment.