From 70cbe4a56578ae3a0b793598666a253a04e0ffd4 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Mon, 4 Jan 2021 15:43:13 +0100 Subject: [PATCH] readline: fix behaviour of Interface plugged to a non-terminal output Fixes: https://github.com/nodejs/node/issues/36773 PR-URL: https://github.com/nodejs/node/pull/36774 Reviewed-By: Colin Ihrig Reviewed-By: Anna Henningsen --- lib/readline.js | 6 +++--- test/parallel/test-repl-no-terminal.js | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 test/parallel/test-repl-no-terminal.js diff --git a/lib/readline.js b/lib/readline.js index ffd2aab5517027..6fe456ec313493 100644 --- a/lib/readline.js +++ b/lib/readline.js @@ -252,9 +252,6 @@ function Interface(input, output, completer, terminal) { input.on('keypress', onkeypress); input.on('end', ontermend); - // Current line - this.line = ''; - this._setRawMode(true); this.terminal = true; @@ -270,6 +267,9 @@ function Interface(input, output, completer, terminal) { self.once('close', onSelfCloseWithTerminal); } + // Current line + this.line = ''; + input.resume(); } diff --git a/test/parallel/test-repl-no-terminal.js b/test/parallel/test-repl-no-terminal.js new file mode 100644 index 00000000000000..60f97b52e26942 --- /dev/null +++ b/test/parallel/test-repl-no-terminal.js @@ -0,0 +1,7 @@ +'use strict'; +const common = require('../common'); + +const repl = require('repl'); +const r = repl.start({ terminal: false }); +r.setupHistory('/nonexistent/file', common.mustSucceed()); +process.stdin.unref?.();