Skip to content

Commit 136a99d

Browse files
committed
fix: *command-line-args*
1 parent 5237cda commit 136a99d

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/uclj/core.clj

+10-6
Original file line numberDiff line numberDiff line change
@@ -801,17 +801,21 @@
801801
(evaluator '(run! require uclj.core/namespaces-to-require))
802802
(cond
803803
(and (first args) (.startsWith (str (first args)) "("))
804-
(println (evaluator (read-string (first args))))
804+
(binding [*command-line-args* (second args)]
805+
(println (evaluator (read-string (first args)))))
805806

806807
(and (first args) (.exists (io/file (first args))))
807-
(do (evaluator `(load-file ~(first args)))
808-
(when (= "--test" (second args))
809-
(let [test-result (apply clojure.test/run-tests (all-test-namespaces))]
810-
(when-not (zero? (:fail test-result))
811-
(System/exit 1)))))
808+
(let [test? (= "--test" (second args))]
809+
(binding [*command-line-args* (if test? (nnext args) (next args))]
810+
(evaluator `(load-file ~(first args))))
811+
(when test?
812+
(let [test-result (apply clojure.test/run-tests (all-test-namespaces))]
813+
(when-not (zero? (:fail test-result))
814+
(System/exit 1)))))
812815

813816
:else ;; interactive mode
814817
(do (println "Welcome to the small interpreter!")
818+
(var-set-reset! #'*command-line-args* args)
815819
(doseq [v [#'*1 #'*2 #'*3 #'*e]] (var-set-reset! v nil))
816820
(loop []
817821
(print (str (ns-name *ns*) "=> ")) (flush)

0 commit comments

Comments
 (0)