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:
parent
cbe25a41b0
commit
c2b58f3a54
1 changed files with 3 additions and 0 deletions
|
|
@ -82,6 +82,9 @@ when not defined(readLineFromStdin):
|
||||||
proc readLineFromStdin(prompt: string, line: var string): bool =
|
proc readLineFromStdin(prompt: string, line: var string): bool =
|
||||||
stdout.write(prompt)
|
stdout.write(prompt)
|
||||||
result = readLine(stdin, line)
|
result = readLine(stdin, line)
|
||||||
|
if not result:
|
||||||
|
stdout.write("\n")
|
||||||
|
quit(0)
|
||||||
|
|
||||||
proc endsWith*(x: string, s: set[char]): bool =
|
proc endsWith*(x: string, s: set[char]): bool =
|
||||||
var i = x.len-1
|
var i = x.len-1
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue