diff --git a/lib/coffee-script/repl.js b/lib/coffee-script/repl.js index 977f4d42..1f0ccfc0 100644 --- a/lib/coffee-script/repl.js +++ b/lib/coffee-script/repl.js @@ -16,7 +16,7 @@ var js; input = input.replace(/\uFF00/g, '\n'); input = input.replace(/(^|[\r\n]+)(\s*)##?(?:[^#\r\n][^\r\n]*|)($|[\r\n])/, '$1$2$3'); - if (/^\s*$/.test(input)) { + if (/^(\()?\s*(\n\))?$/.test(input)) { return cb(null); } try { @@ -24,10 +24,10 @@ filename: filename, bare: true }); + return cb(null, vm.runInContext(js, context, filename)); } catch (err) { - cb(err); + return cb(err); } - return cb(null, vm.runInContext(js, context, filename)); } }; diff --git a/src/repl.coffee b/src/repl.coffee index c0855b43..2d8b873c 100644 --- a/src/repl.coffee +++ b/src/repl.coffee @@ -11,13 +11,13 @@ replDefaults = # strip single-line comments input = input.replace /(^|[\r\n]+)(\s*)##?(?:[^#\r\n][^\r\n]*|)($|[\r\n])/, '$1$2$3' # empty command - return cb null if /^\s*$/.test input + return cb null if /^(\s*|\(\s*\))$/.test input # TODO: fix #1829: pass in-scope vars and avoid accidentally shadowing them by omitting those declarations try js = CoffeeScript.compile "_=(#{input}\n)", {filename, bare: yes} + cb null, vm.runInContext(js, context, filename) catch err cb err - cb null, vm.runInContext(js, context, filename) addMultilineHandler = (repl) -> {rli, inputStream, outputStream} = repl