joyent/node — pull request #3665 by maxdeliso (2012-07-08 09:18:26+00:00)
Title: node dies on unexpected end of input currently

if you do a recent build of node, anything after c40875ee13d8bab0b909e917a12282b06b892037,
you start it, and you type (and hit return):

> a(
...

repl.js:284
if (cmd.trim().match(/^npm /) && !self.bufferedCommand) {
^
TypeError: Cannot call method 'trim' of undefined
at finish (repl.js:284:17)
at REPLServer.self.eval (repl.js:118:5)
at rli.on.e (repl.js:260:20)
at REPLServer.self.eval (repl.js:118:5)
at Interface. (repl.js:250:12)
at Interface.EventEmitter.emit (events.js:88:17)
at Interface._onLine (readline.js:183:10)
at Interface._line (readline.js:504:8)
at Interface._ttyWrite (readline.js:722:14)
at ReadStream. (readline.js:105:12)

node dies. I don't think this is the desired behavior, is it? (not being sarcastic here I don't know if this may actually be desired).

my patch fixes this simply by adding a little block to check if cmd is undefined, and print the appropriate error message if that is the case.

now, with the patch:

> a(
...
SyntaxError: Unexpected end of input
>