`node -e ''` should mean eval(''), not invoke REPL

Fixes #1116
v0.7.4-release
Fuji, Goro 2011-05-29 02:04:36 +09:00 committed by Ryan Dahl
parent 650a308634
commit 8971b59365
2 changed files with 7 additions and 1 deletions

View File

@ -75,7 +75,7 @@
// Main entry point into most programs:
process.nextTick(Module.runMain);
} else if (process._eval) {
} else if (process._eval != null) {
// User passed '-e' or '--eval' arguments to Node.
var Module = NativeModule.require('module');
var rv = new Module()._compile('return eval(process._eval)', 'eval');

View File

@ -47,3 +47,9 @@ child.exec(nodejs + ' --eval "require(\'./test/simple/test-cli-eval.js\')"',
function(status, stdout, stderr) {
assert.equal(status.code, 42);
});
// empty program should do nothing
child.exec(nodejs + ' -e ""', function(status, stdout, stderr) {
assert.equal(stdout, 'undefined\n');
assert.equal(stderr, '');
});