From 8971b593659b4ba48f63a095fb0b9a1bd4662db6 Mon Sep 17 00:00:00 2001 From: "Fuji, Goro" Date: Sun, 29 May 2011 02:04:36 +0900 Subject: [PATCH] `node -e ''` should mean eval(''), not invoke REPL Fixes #1116 --- src/node.js | 2 +- test/simple/test-cli-eval.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/node.js b/src/node.js index 190bbdf21ff..44b61ef9b8e 100644 --- a/src/node.js +++ b/src/node.js @@ -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'); diff --git a/test/simple/test-cli-eval.js b/test/simple/test-cli-eval.js index 27763adaf57..3340d013843 100644 --- a/test/simple/test-cli-eval.js +++ b/test/simple/test-cli-eval.js @@ -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, ''); +});