From 574f61315d015033dbf20e4840a645057b0c2060 Mon Sep 17 00:00:00 2001 From: Timothee Cour Date: Wed, 5 Feb 2020 07:44:19 -0800 Subject: [PATCH] nim secret: support linenoise when available (#13328) --- compiler/llstream.nim | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/llstream.nim b/compiler/llstream.nim index fffc8db48eef2..b550716d6290c 100644 --- a/compiler/llstream.nim +++ b/compiler/llstream.nim @@ -12,9 +12,9 @@ import pathutils -# support '-d:useGnuReadline' for backwards compatibility: -when not defined(windows) and (defined(useGnuReadline) or defined(useLinenoise)): - import rdstdin +template imp(x) = import x +const hasRstdin = compiles(imp(rdstdin)) +when hasRstdin: import rdstdin type TLLRepl* = proc (s: PLLStream, buf: pointer, bufLen: int): int @@ -67,7 +67,7 @@ proc llStreamClose*(s: PLLStream) = of llsFile: close(s.f) -when not declared(readLineFromStdin): +when not hasRstdin: # fallback implementation: proc readLineFromStdin(prompt: string, line: var string): bool = stderr.write(prompt)