Permalink
Browse files

repl: don't interpret floating point numbers

Don't interpret floating point numbers, e.g. ".1234", as REPL commands.

Fixes #4268.
  • Loading branch information...
1 parent 13c5db9 commit b6e989759bfcfdc00d9d4b5a3b32d31ea29838c0 @bnoordhuis bnoordhuis committed Nov 10, 2012
Showing with 4 additions and 1 deletion.
  1. +1 −1 lib/repl.js
  2. +3 −0 test/simple/test-repl.js
View
@@ -206,7 +206,7 @@ function REPLServer(prompt, stream, eval_, useGlobal, ignoreUndefined) {
// Check to see if a REPL keyword was used. If it returns true,
// display next prompt and return.
- if (cmd && cmd.charAt(0) === '.') {
+ if (cmd && cmd.charAt(0) === '.' && cmd != parseFloat(cmd)) {
var matches = cmd.match(/^(\.[^\s]+)\s*(.*)$/);
var keyword = matches && matches[1];
var rest = matches && matches[2];
View
@@ -119,6 +119,9 @@ function error_test() {
// You can recover with the .break command
{ client: client_unix, send: '.break',
expect: prompt_unix },
+ // Floating point numbers are not interpreted as REPL commands.
+ { client: client_unix, send: '.1234',
+ expect: '0.1234' },
// Can parse valid JSON
{ client: client_unix, send: 'JSON.parse(\'{"valid": "json"}\');',
expect: '{ valid: \'json\' }'},

0 comments on commit b6e9897

Please sign in to comment.