From ffe9603c396cf80c29a6ed43aeca60c2f60540f2 Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Mon, 4 Mar 2024 23:11:04 +0000 Subject: [PATCH] remove file-scoped parameters var --- pkgs/ifwait/ifwait.fnl | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/pkgs/ifwait/ifwait.fnl b/pkgs/ifwait/ifwait.fnl index 2bdb19d..3d599f5 100644 --- a/pkgs/ifwait/ifwait.fnl +++ b/pkgs/ifwait/ifwait.fnl @@ -14,33 +14,32 @@ [linkname nil] {:link linkname :expecting "present"} _ nil)) -(local parameters - (or - (parse-args arg) - (assert false (.. "Usage: " (. arg 0) " [-v] ifname [present|up|running]")))) - -(fn run-event [v] +(fn run-event [params v] (let [got (match v ;; - up: Reflects the administrative state of the interface (IFF_UP) ;; - running: Reflects the operational state (IFF_RUNNING). - {:event "newlink" :name parameters.link :up :yes :running :yes} + {:event "newlink" :name params.link :up :yes :running :yes} {:present true :up true :running true} - {:event "newlink" :name parameters.link :up :yes} + {:event "newlink" :name params.link :up :yes} {:present :true :up true} - {:event "newlink" :name parameters.link} + {:event "newlink" :name params.link} {:present true } _ {})] - (when (. got parameters.expecting) + (when (. got params.expecting) (os.exit 0)))) -(when parameters.verbose - (print (.. (. arg 0) ": waiting for " - parameters.link " to be " parameters.expecting))) +(let [parameters + (or + (parse-args arg) + (assert false (.. "Usage: " (. arg 0) " [-v] ifname [present|up|running]")))] + (when parameters.verbose + (print (.. (. arg 0) ": waiting for " + parameters.link " to be " parameters.expecting))) -(each [event (nl.events {:link true})] - (run-event event)) + (each [event (nl.events {:link true})] + (run-event parameters event)))