I’m wondering if the Clojure “-main” function is supposed to have a return value, like the C “main” function? From googling around a bit, I think the answer is “no”, but I am not certain. For now, I am just using a
-main function structure like this, to handle passing the status code back to the OS:
(defn -main "the main function" [& args] (let [status-code (apply main-with-return-status args)] (if (> status-code 0) (let [status-message (str "Status code is: " status-code)] (if (not (is-in-repl)) (do (println->stderr status-message) (System/exit status-code)) (throw (Exception. status-message))) ) ) ) )
or, if the code is running in a REPL, I just throw an exception if the final status-code is nonzero. Is that on the right track?