Permalink
Browse files

repl: do not consider `...` as a REPL command

This fix makes ... in REPL to be considered as a javascript construct
rather than a REPL keyword.

Fixes: #14426
Backport-PR-URL: #14915
PR-URL: #14467
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
  • Loading branch information...
shivanth authored and MylesBorins committed Jul 23, 2017
1 parent 90fcccd commit 362a7c0d8b3fb76964fd824a02a4dd96162f38d6
Showing with 12 additions and 5 deletions.
  1. +5 −4 lib/repl.js
  2. +7 −1 test/parallel/test-repl.js
View
@@ -519,10 +519,11 @@ function REPLServer(prompt,
// Check to see if a REPL keyword was used. If it returns true,
// display next prompt and return.
if (cmd && cmd.charAt(0) === '.' && isNaN(parseFloat(cmd))) {
var matches = cmd.match(/^\.([^\s]+)\s*(.*)$/);
var keyword = matches && matches[1];
var rest = matches && matches[2];
if (cmd && cmd.charAt(0) === '.' && cmd.charAt(1) !== '.' &&
isNaN(parseFloat(cmd))) {
const matches = cmd.match(/^\.([^\s]+)\s*(.*)$/);
const keyword = matches && matches[1];
const rest = matches && matches[2];
if (self.parseREPLKeyword(keyword, rest) === true) {
return;
} else if (!self.bufferedCommand) {
@@ -387,7 +387,13 @@ function error_test() {
{
client: client_unix, send: '(function() {\nif (false) {} /bar"/;\n}())',
expect: `${prompt_multiline}${prompt_multiline}undefined\n${prompt_unix}`
}
},
// Do not parse `...[]` as a REPL keyword
{ client: client_unix, send: '...[]\n',
expect: `${prompt_multiline}` },
// bring back the repl to prompt
{ client: client_unix, send: '.break',
expect: `${prompt_unix}` }
]);
}

0 comments on commit 362a7c0

Please sign in to comment.