-
Notifications
You must be signed in to change notification settings - Fork 64
No input received from terminal #11
Comments
Hi, Gomez var rl = require('readline-sync');
input = rl.prompt();
console.log('NEXT LINE'); |
And, the prompt text (default: |
It stops executing at that point, trying to read input and keeping stuck. And the prompt is displayed correctly, so I am a 99'9% sure it has a problem with receiving input. |
Ummm... readlineSync works completely on my machine, there seems to be no problem. The setup nodejs was no problem? Try this:
/bin/sh `node -e "console.log(require('path').dirname(require.resolve('readline-sync')))"`/read.sh
|
That worked! Forgot to mention before - I had the problem while using the Node interpreter. So guess that's what happened. I was executing my code by invoking Now - could this bug be fixed? It seems that the problem is that node.js may be trying to read the input twice, in two different ways simultaneously. Or something like that. |
Ah, you tried in REPL. I understood. Try this code in REPL: process.stdin.pause() |
Ugh, I apologize. How simple. Guess I'll have to study better the APIs! (and yup, here's someone who wants to read input from REPL. Working on what I consider a cool project. Hi!) |
Actually -- not working. It still keeps stuck. Here's the source code of the "real" thing: var os = require('os');
var rl = require('readline-sync');
var child_process = require('child_process');
var sh = require('execSync');
var username = sh.exec("id -un").stdout.replace(os.EOL, '');
var hostname = os.hostname();
module.exports = {
shell: function (){
console.log( 'Kuen Shell v0.0.1' );
console.log( '2015 Francisco Gómez <espectalll123@outlook.com>' + os.EOL );
process.stdin.pause();
var loop = true;
while(loop) {
rl.setPrompt(username + '@' + hostname + ': ');
input = rl.prompt();
try {
var shExec = sh.exec(input);
console.log(shExec.stdout);
} catch(e) {};
};
}
} |
If you want to read a line from another stream that is not REPL, I think that you must assign another channel (e.g. remote connection). So, your code seems to run with no problem in my machine. (some syntax errors are shown. but it's running.) Try this: var os = require('os');
var rl = require('readline-sync');
var child_process = require('child_process');
//var sh = require('execSync');
// Dummy Object
var sh = {exec: function(cmd) {
return {stdout: 'Res of: ' + cmd};
}};
var username = sh.exec("id -un").stdout.replace(os.EOL, '');
var hostname = os.hostname();
module.exports = {
shell: function (){
console.log( 'Kuen Shell v0.0.1' );
console.log( '2015 Francisco Gómez <espectalll123@outlook.com>' + os.EOL );
process.stdin.pause();
var loop = true;
while(loop) {
rl.setPrompt(username + '@' + hostname + ': ');
input = rl.prompt();
try {
var shExec = sh.exec(input);
console.log(shExec.stdout);
} catch(e) {};
};
}
} |
I didn't try running readlineSync on |
10 days have passed. I think that that problem was already solved, and I close the issue. |
The bug itself still happens. However, I'm going to try out a different workaround for my idea. Thanks! |
Ok. 😊 |
I don't think that's a bug in readline-sync because it happens also if you try a different loop such as a for loop. |
Hi @CreeperDrop, thank you for the comment. Yes, that is not a bug. It was clearly indicated that there was the problem in @espectalll's environment. (e.g. REPL) |
I'm developing a simple shell. Because I wanted the execution of code to be synced, input is managed through readline-sync. However, I've found that trying to do anything (including ^C or ^D) is useless. For example, a very basic code like:
keeps reading without ever responding. The same happens with other commands like
rl.question
. I can only guess that V8 is unable to receive any input, for some reason.I'm running a manually compiled node.js 0.10.35 on Ubuntu 14.04 LTS, using Bash and the GNOME Terminal.
The text was updated successfully, but these errors were encountered: