mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-18 21:40:32 +00:00
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.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user