Fix preloads

This commit is contained in:
Michiel Borkent 2020-02-04 11:09:29 +01:00
parent 1d3eaae943
commit ba3eac83b1

View file

@ -282,6 +282,8 @@ Everything after that is bound to *command-line-args*."))
(handle-pipe!) (handle-pipe!)
#_(binding [*out* *err*] #_(binding [*out* *err*]
(prn "M" (meta (get bindings 'future)))) (prn "M" (meta (get bindings 'future))))
(sci/with-bindings {reflection-var false
vars/current-ns (vars/->SciNamespace 'user)}
(let [t0 (System/currentTimeMillis) (let [t0 (System/currentTimeMillis)
{:keys [:version :shell-in :edn-in :shell-out :edn-out {:keys [:version :shell-in :edn-in :shell-out :edn-out
:help? :file :command-line-args :help? :file :command-line-args
@ -372,15 +374,14 @@ Everything after that is bound to *command-line-args*."))
exit-code exit-code
;; handle preloads ;; handle preloads
(if exit-code exit-code (if exit-code exit-code
(do (when preloads (try (eval-string* sci-ctx preloads) (do (when preloads
(try
(eval-string* sci-ctx preloads)
(catch Throwable e (catch Throwable e
(error-handler* e verbose?)))) (error-handler* e verbose?))))
nil)) nil))
exit-code exit-code
(or exit-code (or exit-code
(sci/with-bindings {reflection-var false
vars/current-ns (vars/->SciNamespace 'user)}
(or
(second (second
(cond version (cond version
[(print-version) 0] [(print-version) 0]
@ -415,7 +416,7 @@ Everything after that is bound to *command-line-args*."))
(error-handler* e verbose?))) (error-handler* e verbose?)))
uberscript [nil 0] uberscript [nil 0]
:else [(repl/start-repl! sci-ctx) 0])) :else [(repl/start-repl! sci-ctx) 0]))
1))) 1)
t1 (System/currentTimeMillis)] t1 (System/currentTimeMillis)]
(flush) (flush)
(when uberscript (when uberscript
@ -428,7 +429,7 @@ Everything after that is bound to *command-line-args*."))
(spit uberscript-out expression :append true))) (spit uberscript-out expression :append true)))
(when time? (binding [*out* *err*] (when time? (binding [*out* *err*]
(println "bb took" (str (- t1 t0) "ms.")))) (println "bb took" (str (- t1 t0) "ms."))))
exit-code)) exit-code)))
(defn -main (defn -main
[& args] [& args]