From 46d3ff2af98e67bbf583fcee1fd2551d8727a181 Mon Sep 17 00:00:00 2001 From: Shivanth MP Date: Sun, 23 Jul 2017 21:47:07 +0530 Subject: [PATCH] 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: https://github.com/nodejs/node/issues/14426 PR-URL: https://github.com/nodejs/node/pull/14467 Reviewed-By: Roman Reiss Reviewed-By: Anna Henningsen Reviewed-By: Jeremiah Senkpiel --- lib/repl.js | 3 ++- test/parallel/test-repl.js | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/repl.js b/lib/repl.js index a201ecc62222b6..22029e6cc3082f 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -419,7 +419,8 @@ function REPLServer(prompt, // Check to see if a REPL keyword was used. If it returns true, // display next prompt and return. if (trimmedCmd) { - if (trimmedCmd.charAt(0) === '.' && isNaN(parseFloat(trimmedCmd))) { + if (trimmedCmd.charAt(0) === '.' && trimmedCmd.charAt(1) !== '.' && + isNaN(parseFloat(trimmedCmd))) { const matches = trimmedCmd.match(/^\.([^\s]+)\s*(.*)$/); const keyword = matches && matches[1]; const rest = matches && matches[2]; diff --git a/test/parallel/test-repl.js b/test/parallel/test-repl.js index 0f2560efb498e6..0e3d9d296f35e8 100644 --- a/test/parallel/test-repl.js +++ b/test/parallel/test-repl.js @@ -414,7 +414,13 @@ function error_test() { expect: `${prompt_multiline}'foo \\n'\n${prompt_unix}` }, // Whitespace is not evaluated. { client: client_unix, send: ' \t \n', - expect: prompt_unix } + expect: 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}` } ]); }