Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node.js REPL funny behavior with custom eval function

It seems that Node.js (version v0.10.13) returns the command wrapped between ( and \n), here's a minimal example:

require('repl').start({
    'eval': function (cmd, context, filename, callback) {
        callback(null, cmd);
    }
});

The behavior is the following:

$ node repl.js
> asd
'(asd\n)'
>

Why is that? If this feature is documented then I was not able to find it.

Also, if this is the intended behavior, is there a better solution than doing cmd = cmd.slice(1, -2);?

like image 501
cYrus Avatar asked Oct 04 '13 13:10

cYrus


1 Answers

The issue is already fixed (see commit 9ef9a9de from Aug 2013). Now only JSON expression is wrapped into parens.

like image 88
ruvim Avatar answered Oct 14 '22 00:10

ruvim