Skip to content

Commit

Permalink
repl: do not consider ... as a REPL command
Browse files Browse the repository at this point in the history
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 Sep 19, 2017
1 parent 90fcccd commit 362a7c0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
9 changes: 5 additions & 4 deletions lib/repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
8 changes: 7 additions & 1 deletion test/parallel/test-repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}` }
]);
}

Expand Down

0 comments on commit 362a7c0

Please sign in to comment.