-
- Notifications
You must be signed in to change notification settings - Fork 33.8k
Open
Labels
readlineIssues and PRs related to the built-in readline module.Issues and PRs related to the built-in readline module.ttyIssues and PRs related to the tty subsystem.Issues and PRs related to the tty subsystem.
Description
- Version: v10.2.1
- Platform: Linux and macOS
- Subsystem: readline
The use case is that a node script is being run from a piped bash script and so process.stdin is the pipe and /dev/tty must be used explicitly to get user input.
var readline = require('readline'); var input = require('fs').createReadStream('/dev/tty'); var rl = readline.createInterface({ input: input , output: process.stdout //, terminal: false }); rl.question("This is the prompt: ", function (response) { console.log("This is the response:", response); rl.close(); // If I don't close the input explicitly, it stays open. input.close(); });Output:
This is the prompt: yay yay This is the response: yay Uncommenting terminal: false solves the issue of echoing, but creates a new problem in that it no longer treats stdout as a proper terminal.
Past issues that appear to be similar: #7965 nodejs/node-v0.x-archive#7101 https://stackoverflow.com/questions/24661774/createinterface-prints-double-in-terminal
eriegz
Metadata
Metadata
Assignees
Labels
readlineIssues and PRs related to the built-in readline module.Issues and PRs related to the built-in readline module.ttyIssues and PRs related to the tty subsystem.Issues and PRs related to the tty subsystem.