summaryrefslogtreecommitdiff
path: root/lib/readline.js
diff options
context:
space:
mode:
authorcjihrig <cjihrig@gmail.com>2019-08-15 12:37:29 -0400
committercjihrig <cjihrig@gmail.com>2019-08-17 15:49:45 -0400
commit93b341ed01a735f671c84e72a30e5e55945ea27f (patch)
tree1a1b8973caf3e806856f25e95b0f9614ec0f3067 /lib/readline.js
parenta5edceea0416ad911ffdbc9b6a93eb3630d1a550 (diff)
downloadandroid-node-v8-93b341ed01a735f671c84e72a30e5e55945ea27f.tar.gz
android-node-v8-93b341ed01a735f671c84e72a30e5e55945ea27f.tar.bz2
android-node-v8-93b341ed01a735f671c84e72a30e5e55945ea27f.zip
readline: close dumb terminals on Control+D
This commit adds support for closing a readline interface on Control+D when the terminal is dumb. PR-URL: https://github.com/nodejs/node/pull/29149 Fixes: https://github.com/nodejs/node/issues/29111 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Diffstat (limited to 'lib/readline.js')
-rw-r--r--lib/readline.js19
1 files changed, 12 insertions, 7 deletions
diff --git a/lib/readline.js b/lib/readline.js
index 540a7a6062..301b6f8160 100644
--- a/lib/readline.js
+++ b/lib/readline.js
@@ -816,15 +816,20 @@ function _ttyWriteDumb(s, key) {
if (this._sawReturnAt && key.name !== 'enter')
this._sawReturnAt = 0;
- if (key.ctrl && key.name === 'c') {
- if (this.listenerCount('SIGINT') > 0) {
- this.emit('SIGINT');
- } else {
- // This readline instance is finished
+ if (key.ctrl) {
+ if (key.name === 'c') {
+ if (this.listenerCount('SIGINT') > 0) {
+ this.emit('SIGINT');
+ } else {
+ // This readline instance is finished
+ this.close();
+ }
+
+ return;
+ } else if (key.name === 'd') {
this.close();
+ return;
}
-
- return;
}
switch (key.name) {