summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorReimer Behrends <behrends@gmail.com>2014-06-02 19:38:51 +0200
committerReimer Behrends <behrends@gmail.com>2014-06-02 19:38:51 +0200
commitc2b58f3a542655d877c2b6f6662466338cc4606b (patch)
treed62701dc4c7f41cc5a894175308b7a2e89cd5dd5
parentcbe25a41b031ea8c36dce1b47c26fd7682e40a82 (diff)
downloadNim-c2b58f3a542655d877c2b6f6662466338cc4606b.tar.gz
Properly terminate "nimrod i" on end of file.
Nimrod in interactive mode got stuck in an infinite loop when
encountering EOF (Ctrl-D), unless GNU Readline was being used. This
change mimics the GNU Readline behavior in rdstdin.nim and calls quit(0)
when encountering EOF while reading from stdin in interactive mode.
-rw-r--r--compiler/llstream.nim3
1 files changed, 3 insertions, 0 deletions
diff --git a/compiler/llstream.nim b/compiler/llstream.nim
index 510880ffd..86bfeaabd 100644
--- a/compiler/llstream.nim
+++ b/compiler/llstream.nim
@@ -82,6 +82,9 @@ when not defined(readLineFromStdin):
   proc readLineFromStdin(prompt: string, line: var string): bool =
     stdout.write(prompt)
     result = readLine(stdin, line)
+    if not result:
+      stdout.write("\n")
+      quit(0)
 
 proc endsWith*(x: string, s: set[char]): bool =
   var i = x.len-1