repl: better empty line handling
In REPL, if we try to evaluate an empty line, we get `undefined`. > process.version 'v2.3.4' > undefined > undefined > This patch prevents `undefined` from printing if the string is empty. > process.version 'v2.3.5-pre' > > > PR-URL: https://github.com/nodejs/io.js/pull/2163 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
This commit is contained in:
parent
81ea52aa01
commit
afd7e37ee0
@ -357,7 +357,7 @@ function REPLServer(prompt,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!skipCatchall) {
|
if (!skipCatchall && (cmd || (!cmd && self.bufferedCommand))) {
|
||||||
var evalCmd = self.bufferedCommand + cmd;
|
var evalCmd = self.bufferedCommand + cmd;
|
||||||
if (/^\s*\{/.test(evalCmd) && /\}\s*$/.test(evalCmd)) {
|
if (/^\s*\{/.test(evalCmd) && /\}\s*$/.test(evalCmd)) {
|
||||||
// It's confusing for `{ a : 1 }` to be interpreted as a block
|
// It's confusing for `{ a : 1 }` to be interpreted as a block
|
||||||
|
@ -225,6 +225,13 @@ function error_test() {
|
|||||||
// using REPL command "help" within a string literal should still work
|
// using REPL command "help" within a string literal should still work
|
||||||
{ client: client_unix, send: '\'thefourth\\\n.help\neye\'',
|
{ client: client_unix, send: '\'thefourth\\\n.help\neye\'',
|
||||||
expect: /'thefourtheye'/ },
|
expect: /'thefourtheye'/ },
|
||||||
|
// empty lines in the REPL should be allowed
|
||||||
|
{ client: client_unix, send: '\n\r\n\r\n',
|
||||||
|
expect: prompt_unix + prompt_unix + prompt_unix },
|
||||||
|
// empty lines in the string literals should not affect the string
|
||||||
|
{ client: client_unix, send: '\'the\\\n\\\nfourtheye\'\n',
|
||||||
|
expect: prompt_multiline + prompt_multiline +
|
||||||
|
'\'thefourtheye\'\n' + prompt_unix },
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user