summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFedor Indutny <fedor.indutny@gmail.com>2011-11-03 04:38:38 +0600
committerRyan Dahl <ry@tinyclouds.org>2011-11-02 15:55:36 -0700
commit9ad27f7853089bd24f1093f1617b68808fc87457 (patch)
tree63c3d59212d48a475ab505524b2e3b4a38d3a0e4
parentc8646e0c4159aa53b2ae94d1b69850ce5fa62ca2 (diff)
downloadnodejs-9ad27f7853089bd24f1093f1617b68808fc87457.tar.gz
nodejs-9ad27f7853089bd24f1093f1617b68808fc87457.tar.bz2
nodejs-9ad27f7853089bd24f1093f1617b68808fc87457.zip
ignore undefined messages in the debugger repl
fixes #1995
-rw-r--r--doc/api/repl.markdown5
-rw-r--r--lib/_debugger.js2
-rw-r--r--lib/repl.js4
3 files changed, 7 insertions, 4 deletions
diff --git a/doc/api/repl.markdown b/doc/api/repl.markdown
index 1b8ce246a..9e4246660 100644
--- a/doc/api/repl.markdown
+++ b/doc/api/repl.markdown
@@ -27,7 +27,7 @@ For example, you could add this to your bashrc file:
alias node="env NODE_NO_READLINE=1 rlwrap node"
-### repl.start(prompt='> ', stream=process.stdin, eval=eval, useGlobal=false)
+### repl.start(prompt='> ', stream=process.stdin, eval=eval, useGlobal=false, ignoreUndefined=false)
Starts a REPL with `prompt` as the prompt and `stream` for all I/O. `prompt`
is optional and defaults to `> `. `stream` is optional and defaults to
@@ -36,6 +36,9 @@ is optional and defaults to `> `. `stream` is optional and defaults to
If `useGlobal` is set to true, then the repl will use the global object,
instead of running scripts in a separate context.
+If `ignoreUndefined` is set to true, then the repl will not output return value
+of command if it's `undefined`.
+
You can use your own `eval` function if it has following signature:
function eval(cmd, callback) {
diff --git a/lib/_debugger.js b/lib/_debugger.js
index 1269f56a2..a6bc213e0 100644
--- a/lib/_debugger.js
+++ b/lib/_debugger.js
@@ -724,7 +724,7 @@ function Interface(stdin, stdout, args) {
// Two eval modes are available: controlEval and debugEval
// But controlEval is used by default
this.repl = new repl.REPLServer('debug> ', streams,
- this.controlEval.bind(this));
+ this.controlEval.bind(this), false, true);
// Kill child process when repl closed or main process is dead
this.repl.rli.addListener('close', function() {
diff --git a/lib/repl.js b/lib/repl.js
index 6f58f7647..bbe658a8a 100644
--- a/lib/repl.js
+++ b/lib/repl.js
@@ -68,7 +68,7 @@ module.paths = require('module')._nodeModulePaths(module.filename);
exports.writer = util.inspect;
-function REPLServer(prompt, stream, eval, useGlobal) {
+function REPLServer(prompt, stream, eval, useGlobal, ignoreUndefined) {
var self = this;
self.useGlobal = useGlobal;
@@ -224,7 +224,7 @@ function REPLServer(prompt, stream, eval, useGlobal) {
self.bufferedCommand = '';
// If we got any output - print it (if no error)
- if (!e) {
+ if (!e && (!ignoreUndefined || ret !== undefined)) {
self.context._ = ret;
self.outputStream.write(exports.writer(ret) + '\n');
}