eufon

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 67e03c673624616938ff3db45197dcb9474da07a
parent 60d44668573a9ef44cdc7137c5f4d1e2bc7249fa
Author: Daniel Barlow <dan@telent.net>
Date:   Sun,  3 Jul 2022 11:09:02 +0100

extract function

Diffstat:
Msocket-repl.fnl | 14+++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/socket-repl.fnl b/socket-repl.fnl @@ -20,6 +20,12 @@ (on-connected connected-fd))) )) +(fn get-input [fd] + (let [buf (unistd.read fd 1024)] + (if (and buf (> (# buf) 0)) + buf + "\n,exit"))) + (fn start [pathname] (unistd.unlink pathname) (unix-socket-listener @@ -29,17 +35,11 @@ repl-coro (coroutine.create repl)] (watch-fd fd fcntl.O_RDONLY (fn [fd] - (let [buf (unistd.read fd 1024) - input - (if (and buf (> (# buf) 0)) - buf - "\n,exit")] - (coroutine.resume repl-coro input)) + (coroutine.resume repl-coro (get-input fd)) (if (= (coroutine.status repl-coro) :dead) (do (sock:write "bye!\n") (sock:close) - (unistd.close fd) false) true )))