mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 15:57:35 +00:00
Shell: Exit the shell on (interactive) EOF with empty buffer
In other words, if the user presses EOF (normally Ctrl+D), we now print out "<EOF>" and exit the shell without error. Fixes #701.
This commit is contained in:
parent
390b219cd1
commit
845094f9e4
1 changed files with 7 additions and 0 deletions
|
@ -302,6 +302,13 @@ String LineEditor::get_line(const String& prompt)
|
||||||
}
|
}
|
||||||
continue;
|
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 (ch == 0x05) { // ^E
|
||||||
if (m_cursor < m_buffer.size()) {
|
if (m_cursor < m_buffer.size()) {
|
||||||
printf("\033[%dC", m_buffer.size() - m_cursor);
|
printf("\033[%dC", m_buffer.size() - m_cursor);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue