node.js readline - write data appears in input -
i've got basic readline implementation seems have problem when write written data appears in input , raises 'line' event. in standard linux rxvt window.
var rl readline.createinterface({ input: process.stdin, output: process.stdout, // terminal: false <--- setting true/false makes no difference }); rl.on('line', function(line) { var inp = line.trim(); console.log('line event'); switch(inp) { case .... default: console.log('unknown command: ' + inp + '\n'); } });
and rl.write(string);
from socket i/o. write raises 'line' event , written data apears unknown command.
if enter data on terminal raises 'line' event expected , works ok.
clearly data written shouldn't appear on input , asking might reason this.
thanks
actually rl.write
trigger line event. should in docs isn't. if want bypass parser write process.stdout.
previously terminal: false
cause output have trailing endline, forcing line event trigger. give true avoid that, has been changed changing option won't help.
see raised issue. last comment says same.
Comments
Post a Comment