diff options
Diffstat (limited to 'lib/repl.js')
-rw-r--r-- | lib/repl.js | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/repl.js b/lib/repl.js index 20fa7aefc7..7bbc6d1448 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -130,7 +130,7 @@ function REPLServer(prompt, stream, eval, useGlobal, ignoreUndefined) { var sawSIGINT = false; rli.on('SIGINT', function() { if (sawSIGINT) { - rli.close(); + rli.pause(); process.exit(); } @@ -185,7 +185,9 @@ function REPLServer(prompt, stream, eval, useGlobal, ignoreUndefined) { function(e, ret) { if (e && !isSyntaxError(e)) return finish(e); - if (typeof ret === 'function' || e) { + if (typeof ret === 'function' && + /^[\r\n\s]*function/.test(evalCmd) || + e) { // Now as statement without parens. self.eval(evalCmd, self.context, 'repl', finish); } else { @@ -282,11 +284,11 @@ REPLServer.prototype.resetContext = function(force) { this.context = context; }; -REPLServer.prototype.displayPrompt = function() { +REPLServer.prototype.displayPrompt = function(preserveCursor) { this.rli.setPrompt(this.bufferedCommand.length ? '...' + new Array(this.lines.level.length).join('..') + ' ' : this.prompt); - this.rli.prompt(); + this.rli.prompt(preserveCursor); }; @@ -738,7 +740,7 @@ function defineDefaultCommands(repl) { repl.defineCommand('exit', { help: 'Exit the repl', action: function() { - this.rli.close(); + this.rli.pause(); } }); |