From 965c177bca31ae9882c975ef7db448e12f59984e Mon Sep 17 00:00:00 2001 From: Gabe Date: Wed, 14 Dec 2022 15:57:07 +0200 Subject: [PATCH] Fix #1280: babashka REPL doesn't quit right after ctrl-d (#1450) the problem is that parser/parse-next waits for an enter before returning an object we can use peek-char to pre-emptively react to any EOF at the start of the line in case of not-start-of-line, parse-next takes over Co-authored-by: Alice Margatroid --- src/babashka/impl/repl.clj | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/babashka/impl/repl.clj b/src/babashka/impl/repl.clj index e1083b5b..11dcf370 100644 --- a/src/babashka/impl/repl.clj +++ b/src/babashka/impl/repl.clj @@ -63,13 +63,14 @@ (eval-form sci-ctx `(apply require (quote ~m/repl-requires))))) :read (or read (fn [_request-prompt request-exit] - (let [v (parser/parse-next sci-ctx in)] - (skip-if-eol in) - (if (or (identical? :repl/quit v) - (identical? :repl/exit v) - (identical? parser/eof v)) - request-exit - v)))) + (if (nil? (r/peek-char in)) + request-exit + (let [v (parser/parse-next sci-ctx in)] + (skip-if-eol in) + (if (or (identical? :repl/quit v) + (identical? :repl/exit v)) + request-exit + v))))) :eval (or eval (fn [expr] (sci/with-bindings {sci/file ""