From b45698e67629a894cc005efba5c39d0e8adae1b0 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Sat, 1 Jan 2011 17:54:45 -0800 Subject: [PATCH] Improve how REPL commands are evaled Before: > {a: 1} 1 > (function() { ... // foo ... return 1; ... })(); ... Now: > {a: 1} { a : 1 } > (function() { ... // foo ... return 1; ... })(); 1 > --- lib/repl.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/repl.js b/lib/repl.js index 4d144f17cd..04f8696ef3 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -104,12 +104,12 @@ function REPLServer(prompt, stream) { if (!skipCatchall) { // The catchall for errors try { - self.buffered_cmd += cmd; + self.buffered_cmd += '\n' + cmd; // This try is for determining if the command is complete, or should // continue onto the next line. try { // Use evalcx to supply the global context - var ret = evalcx(self.buffered_cmd, context, 'repl'); + var ret = evalcx('(' + self.buffered_cmd + ')', context, 'repl'); if (ret !== undefined) { context._ = ret; self.stream.write(exports.writer(ret) + '\n');