diff --git a/bin/node-repl b/bin/node-repl index c23fb49643..b2b5d6cb35 100755 --- a/bin/node-repl +++ b/bin/node-repl @@ -1,8 +1,9 @@ #!/usr/bin/env node -puts = require("sys").puts; +var puts = require("sys").puts; puts("Type '.help' for options."); +puts("(The REPL can also be started by typing 'node' without arguments)"); require('repl').start(); diff --git a/lib/module.js b/lib/module.js index 0ae4a4b9c1..2f9005290a 100644 --- a/lib/module.js +++ b/lib/module.js @@ -441,16 +441,6 @@ Module.prototype._waitChildrenLoad = function (callback) { // bootstrap main module. exports.runMain = function () { - var cwd = process.cwd(); - - // Make process.argv[0] and process.argv[1] into full paths. - if (process.argv[0].indexOf('/') > 0) { - process.argv[0] = path.join(cwd, process.argv[0]); - } - - if (process.argv[1].charAt(0) != "/" && !(/^http:\/\//).exec(process.argv[1])) { - process.argv[1] = path.join(cwd, process.argv[1]); - } // Load the main module--the command line argument. process.mainModule = new Module("."); diff --git a/src/node.cc b/src/node.cc index cabe462623..1a45d3a233 100644 --- a/src/node.cc +++ b/src/node.cc @@ -2098,14 +2098,6 @@ int main(int argc, char *argv[]) { // in the command line)) V8::SetFlagsFromCommandLine(&node::option_end_index, argv, false); - // Error out if we don't have a script argument. - if (argc < 2) { - fprintf(stderr, "No script was specified.\n"); - node::PrintHelp(); - return 1; - } - - // Ignore SIGPIPE struct sigaction sa; bzero(&sa, sizeof(sa)); diff --git a/src/node.js b/src/node.js index a17ba6f697..2b7b00b775 100644 --- a/src/node.js +++ b/src/node.js @@ -192,9 +192,26 @@ process.exit = function (code) { process.reallyExit(code); }; +var cwd = process.cwd(); +var path = module.requireNative('path'); -module.runMain(); +// Make process.argv[0] and process.argv[1] into full paths. +if (process.argv[0].indexOf('/') > 0) { + process.argv[0] = path.join(cwd, process.argv[0]); +} + +if (process.argv[1]) { + if (process.argv[1].charAt(0) != "/" && !(/^http:\/\//).exec(process.argv[1])) { + process.argv[1] = path.join(cwd, process.argv[1]); + } + module.runMain(); +} else { + // No arguments, run the repl + var repl = module.requireNative('repl'); + process.stdout.write("Type '.help' for options.\n"); + repl.start(); +} // All our arguments are loaded. We've evaluated all of the scripts. We // might even have created TCP servers. Now we enter the main eventloop. If