Repository navigation
Unable to exit REPL via escape codes when TERM=dumb #29111
Copy link
Copy link
Closed
Labels
replIssues and PRs related to the REPL subsystem.Issues and PRs related to the REPL subsystem.
Description
Activity
- addedreplIssues and PRs related to the REPL subsystem.Issues and PRs related to the REPL subsystem.
on Aug 13, 2019 I don't think it's unexpected: the terminfo entry for 'dumb' basically says it doesn't support anything except ^G (bel).
On the other hand, lib/readline.js has some emulation baked in and teaching it about ^D isn't hard:
diff --git a/lib/readline.js b/lib/readline.js index b741557a4d..1e7047ce1d 100644 --- a/lib/readline.js +++ b/lib/readline.js @@ -825,6 +825,9 @@ function _ttyWriteDumb(s, key) { } } + if (key.ctrl && key.name === 'd') + this.close(); + switch (key.name) { case 'return': // Carriage return, i.e. \r this._sawReturnAt = Date.now();
The reason ^C doesn't work is because the first ^C leaves a
\x03character (the C in ^C) in the command buffer and that trips up this logic:
Lines 633 to 638 in 427e534
const empty = self.line.length === 0; self.clearLine(); _turnOffEditorMode(self); const cmd = self[kBufferedCommandSymbol]; if (!(cmd && cmd.length > 0) && empty) { This change in
_ttyWriteDumb()fixes the Control+C issue. I'm not sure if it's correct.diff --git a/lib/readline.js b/lib/readline.js index b741557a4d..0606b63585 100644 --- a/lib/readline.js +++ b/lib/readline.js @@ -823,6 +823,8 @@ function _ttyWriteDumb(s, key) { // This readline instance is finished this.close(); } + + return; } switch (key.name) {
And, like Ben mentioned, the code doesn't currently support Control+D. It looks like it was never added in the original PR.
Control+D would trigger end of stdin stream in most terminal, which has handled by readline.
- added 2 commits that reference this issue
on Aug 17, 2019
Metadata
Metadata
Assignees
Labels
replIssues and PRs related to the REPL subsystem.Issues and PRs related to the REPL subsystem.
^Cor^Ddo not exit the REPL whenTERM=dumbis set. Is this expected?