diff --git a/lib/repl.js b/lib/repl.js index d6a5425380a..4ce849a35c8 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -140,20 +140,22 @@ function REPLServer(prompt, stream, eval, useGlobal, ignoreUndefined) { rli.on('SIGINT', function() { rli.output.write('\n'); - if (sawSIGINT) { - rli.pause(); - self.emit('exit'); + if (!(self.bufferedCommand && self.bufferedCommand.length > 0) && + rli.line.length === 0) { + if (sawSIGINT) { + rli.pause(); + self.emit('exit'); + sawSIGINT = false; + return; + } + rli.output.write('(^C again to quit)\n'); + sawSIGINT = true; + } else { sawSIGINT = false; - return; } rli.line = ''; - if (!(self.bufferedCommand && self.bufferedCommand.length > 0)) { - rli.output.write('(^C again to quit)\n'); - sawSIGINT = true; - } - self.bufferedCommand = ''; self.displayPrompt(); });