repl: do not consider `...` as a REPL command · nodejs/node@362a7c0

2 files changed

lines changed

Original file line numberDiff line numberDiff line change

@@ -519,10 +519,11 @@ function REPLServer(prompt,

519519
520520

// Check to see if a REPL keyword was used. If it returns true,

521521

// display next prompt and return.

522-

if (cmd && cmd.charAt(0) === '.' && isNaN(parseFloat(cmd))) {

523-

var matches = cmd.match(/^\.([^\s]+)\s*(.*)$/);

524-

var keyword = matches && matches[1];

525-

var rest = matches && matches[2];

522+

if (cmd && cmd.charAt(0) === '.' && cmd.charAt(1) !== '.' &&

523+

isNaN(parseFloat(cmd))) {

524+

const matches = cmd.match(/^\.([^\s]+)\s*(.*)$/);

525+

const keyword = matches && matches[1];

526+

const rest = matches && matches[2];

526527

if (self.parseREPLKeyword(keyword, rest) === true) {

527528

return;

528529

} else if (!self.bufferedCommand) {

Original file line numberDiff line numberDiff line change

@@ -387,7 +387,13 @@ function error_test() {

387387

{

388388

client: client_unix, send: '(function() {\nif (false) {} /bar"/;\n}())',

389389

expect: `${prompt_multiline}${prompt_multiline}undefined\n${prompt_unix}`

390-

}

390+

},

391+

// Do not parse `...[]` as a REPL keyword

392+

{ client: client_unix, send: '...[]\n',

393+

expect: `${prompt_multiline}` },

394+

// bring back the repl to prompt

395+

{ client: client_unix, send: '.break',

396+

expect: `${prompt_unix}` }

391397

]);

392398

}

393399