-
Notifications
You must be signed in to change notification settings - Fork 29.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
REPL bug fixes #2163
REPL bug fixes #2163
Conversation
24f85ef
to
498eccb
Compare
None of the CI failures are because of this change. Yay :-) |
expect: /'thefourtheye'/ }, | ||
// empty lines in the REPL should be allowed | ||
{ client: client_unix, send: '\n\n\n', | ||
expect: prompt_unix + prompt_unix + prompt_unix }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest also trying \r
and other related characters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also: os.EOL
The other three LGTM, but maybe if @chrisdickinson could review just thefourtheye@498eccb / r |
Also @thefourtheye anywhere you modify or add a variable that could be a |
} else if (isWithinStrLiteral && !wasWithinStrLiteral) { | ||
// was not part of a string literal, but it is now, trim only the start | ||
cmd = cmd.replace(/^\s+/, ''); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just yesterday I learned about String.prototype.trimLeft()
and String.prototype.trimRight()
. These are nonstandard, but there's some discussion about standardizing them on the es-discuss mailing list, so I think we're safe to use them. Also, on the first case, let's use standard String.prototype.trim()
:)
8cb8083
to
ccece25
Compare
@Fishrock123 @silverwind I addressed all the review comments (no exceptions, I addressed them all). PTAL now :-) PS: I rebased with |
When an invalid REPL keyword is used, we actually print `undefined` as well in the console. > process.version 'v2.3.4' > .invalid_repl_command Invalid REPL keyword undefined > This patch prevents printing `undefined` in this case. > process.version 'v2.3.5-pre' > .invalid_repl_command Invalid REPL keyword >
When an inherited property is used as a REPL keyword, the REPL crashes. ➜ Desktop iojs > process.version 'v2.3.4' > .toString readline.js:913 stream[ESCAPE_DECODER].next(r[i]); ^ TypeError: Cannot read property 'call' of undefined at REPLServer.parseREPLKeyword (repl.js:746:15) at REPLServer.<anonymous> (repl.js:284:16) at emitOne (events.js:77:13) at REPLServer.emit (events.js:169:7) at REPLServer.Interface._onLine (readline.js:210:10) at REPLServer.Interface._line (readline.js:549:8) at REPLServer.Interface._ttyWrite (readline.js:826:14) at ReadStream.onkeypress (readline.js:105:10) at emitTwo (events.js:87:13) at ReadStream.emit (events.js:172:7) ➜ Desktop This patch makes the internal `commands` object inherit from `null` so that there will be no inherited properties. > process.version 'v2.3.5-pre' > .toString Invalid REPL keyword >
ccece25
to
aac19e2
Compare
{ client: client_unix, send: '\'thefourth\\\n.help\neye\'', | ||
expect: /'thefourtheye'/ }, | ||
// empty lines in the REPL should be allowed | ||
{ client: client_unix, send: '\n\r\n\r\n', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also: os.EOL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Fishrock123 Other places in the test also use \n
only and they seem to work fine in Windows also (we never had any failures in Win32 land because of this, right?) Moreover the test itself is called as unix_tests
. Should we really change this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I'm not really sure, perhaps it should be in it's own test bit. I guess it's not really necessary.
Two nits. LGTM. Please re-run the CI after you add |
As it is, REPL doesn't honour the line continuation feature very well. This patch 1. keeps track of the beginning of the string literals and if they don't end or current line doesn't end with line continuation, then error out. 2. monitors if the line continuation character is used without the string literal and errors out if that happens.
In REPL, if we try to evaluate an empty line, we get `undefined`. > process.version 'v2.3.4' > undefined > undefined > This patch prevents `undefined` from printing if the string is empty. > process.version 'v2.3.5-pre' > > >
aac19e2
to
b54f153
Compare
Here's a new CI then. Land if it's green(-ish). https://jenkins-iojs.nodesource.com/view/iojs/job/iojs+any-pr+multi/187/ |
@Fishrock123 Except the win2008r2 (which fails with Edit: The problematic win2008r2 CI job link |
@thefourtheye yeah do the thing, that just looks like jenkins hasn't had enough coffee or something. Edit: looks like the windows2008r2-1 machine is having issues. |
When an invalid REPL keyword is used, we actually print `undefined` as well in the console. > process.version 'v2.3.4' > .invalid_repl_command Invalid REPL keyword undefined > This patch prevents printing `undefined` in this case. > process.version 'v2.3.5-pre' > .invalid_repl_command Invalid REPL keyword > PR-URL: #2163 Reviewed-By: Jeremiah Senkpiel <[email protected]>
When an inherited property is used as a REPL keyword, the REPL crashes. ➜ Desktop iojs > process.version 'v2.3.4' > .toString readline.js:913 stream[ESCAPE_DECODER].next(r[i]); ^ TypeError: Cannot read property 'call' of undefined at REPLServer.parseREPLKeyword (repl.js:746:15) at REPLServer.<anonymous> (repl.js:284:16) at emitOne (events.js:77:13) at REPLServer.emit (events.js:169:7) at REPLServer.Interface._onLine (readline.js:210:10) at REPLServer.Interface._line (readline.js:549:8) at REPLServer.Interface._ttyWrite (readline.js:826:14) at ReadStream.onkeypress (readline.js:105:10) at emitTwo (events.js:87:13) at ReadStream.emit (events.js:172:7) ➜ Desktop This patch makes the internal `commands` object inherit from `null` so that there will be no inherited properties. > process.version 'v2.3.5-pre' > .toString Invalid REPL keyword > PR-URL: #2163 Reviewed-By: Jeremiah Senkpiel <[email protected]>
As it is, REPL doesn't honour the line continuation feature very well. This patch 1. keeps track of the beginning of the string literals and if they don't end or current line doesn't end with line continuation, then error out. 2. monitors if the line continuation character is used without the string literal and errors out if that happens. PR-URL: #2163 Reviewed-By: Jeremiah Senkpiel <[email protected]>
In REPL, if we try to evaluate an empty line, we get `undefined`. > process.version 'v2.3.4' > undefined > undefined > This patch prevents `undefined` from printing if the string is empty. > process.version 'v2.3.5-pre' > > > PR-URL: #2163 Reviewed-By: Jeremiah Senkpiel <[email protected]>
Thanks @Fishrock123 :-) Landed at afd7e37, 81ea52a, 30edb5a and 77fa385 |
Tweak the better empty line handling introduced in nodejs#2163 so that empty lines are still passed to the eval function. This is required for the debugger to repeat the last command on an empty line. Fixes: nodejs#6010
There are four bug fixes.
1. Better line continuation feature
As it is, REPL doesn't honour the line continuation feature very well.
This patch
don't end or current line doesn't end with line continuation, then
error out.
string literal and errors out if that happens.
2. Removing
undefined
when unknown REPL command is usedWhen an invalid REPL keyword is used, we actually print
undefined
aswell in the console.
This patch prevents printing
undefined
in this case.3. preventing REPL crash with inherited properties
When an inherited property is used as a REPL keyword, the REPL crashes.
This patch makes the internal
commands
object inherit fromnull
sothat there will be no inherited properties.
4. Better empty line handling
In REPL, if we try to evaluate an empty line, we get
undefined
.This patch prevents
undefined
from printing if the string is empty.