Skip to content

Commit a3c2b55

Browse files
committed
REPL: Tread EOF a "no" in the "yes"/"no" prompt.
Before, we got in an endless loop if using ^D to try to end the session. When piping commands into the REPL, this was rather annoying! ``` scala-hash v2.11.5 Welcome to Scala version 2.11.5-20150101-184742-3fafbc204f (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_25). Type in expressions to have them evaluated. Type :help for more information. scala> :require xxx java.lang.NullPointerException at scala.tools.nsc.interpreter.ILoop.scala$tools$nsc$interpreter$ILoop$$flatten$1(ILoop.scala:651) at scala.tools.nsc.interpreter.ILoop.require(ILoop.scala:654) That entry seems to have slain the compiler. Shall I replay your session? I can re-run each line except the last one. [y/n]^D You must enter y or n. That entry seems to have slain the compiler. Shall I replay your session? I can re-run each line except the last one. [y/n]^D ... ```
1 parent 09ce5c3 commit a3c2b55

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/repl/scala/tools/nsc/interpreter/InteractiveReader.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ trait InteractiveReader {
2323
def readYesOrNo(prompt: String, alt: => Boolean): Boolean = readOneKey(prompt) match {
2424
case 'y' => true
2525
case 'n' => false
26+
case -1 => false // EOF
2627
case _ => alt
2728
}
2829

0 commit comments

Comments
 (0)