diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2015-01-16 11:38:44 +1000 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2015-01-16 11:38:44 +1000 |
commit | a3c2b55b16ad404b51f4eea0628dd00badeb0fbe (patch) | |
tree | 6b508b6008c1aa8f502eb826b0bd0954270817da | |
parent | 09ce5c32f1db71ccaa5d4b22076d9ec606ad5ec9 (diff) | |
download | scala-a3c2b55b16ad404b51f4eea0628dd00badeb0fbe.tar.gz scala-a3c2b55b16ad404b51f4eea0628dd00badeb0fbe.tar.bz2 scala-a3c2b55b16ad404b51f4eea0628dd00badeb0fbe.zip |
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
...
```
-rw-r--r-- | src/repl/scala/tools/nsc/interpreter/InteractiveReader.scala | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/repl/scala/tools/nsc/interpreter/InteractiveReader.scala b/src/repl/scala/tools/nsc/interpreter/InteractiveReader.scala index 28ddf2939c..ed69d449cb 100644 --- a/src/repl/scala/tools/nsc/interpreter/InteractiveReader.scala +++ b/src/repl/scala/tools/nsc/interpreter/InteractiveReader.scala @@ -23,6 +23,7 @@ trait InteractiveReader { def readYesOrNo(prompt: String, alt: => Boolean): Boolean = readOneKey(prompt) match { case 'y' => true case 'n' => false + case -1 => false // EOF case _ => alt } |