upgrade sci (#30)

This commit is contained in:
Michiel Borkent 2019-08-27 00:06:25 +02:00 committed by GitHub
parent 284cee583d
commit b139664e56
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 10 deletions

2
sci

@ -1 +1 @@
Subproject commit e2924e43257fc990d1e7074d7fe23247660e1aad
Subproject commit bbd6b444187607c63c0f9570bfb836f2c9eaac50

View file

@ -80,16 +80,12 @@
--time: print execution time before exiting.
"))
(defn wrap-do [s]
(format "(do %s)" s))
(defn read-file [file]
(let [f (io/file file)]
(if (.exists f)
(as-> (slurp file) x
;; remove shebang
(str/replace x #"^#!.*" "")
(wrap-do x))
(str/replace x #"^#!.*" ""))
(throw (Exception. (str "File does not exist: " file))))))
(defn get-env
@ -157,8 +153,7 @@
(System/setProperty "javax.net.ssl.tru stAnchors" ca-certs)))
(defn load-file* [ctx file]
(let [s (slurp file)
s (wrap-do s)]
(let [s (slurp file)]
(sci/eval-string s ctx)))
(defn main
@ -181,7 +176,7 @@
ctx {:bindings (assoc bindings '*command-line-args* command-line-args)
:env env}
ctx (update ctx :bindings assoc 'load-file #(load-file* ctx %))
_preloads (some-> (System/getenv "BABASHKA_PRELOADS") (str/trim) (wrap-do) (sci/eval-string ctx))
_preloads (some-> (System/getenv "BABASHKA_PRELOADS") (str/trim) (sci/eval-string ctx))
exit-code
(or
#_(binding [*out* *err*]
@ -193,7 +188,7 @@
[(print-help) 0]
:else
(try
(let [expr (if file (read-file file) (wrap-do expression))]
(let [expr (if file (read-file file) expression)]
(loop [in (read-next)]
(let [ctx (update ctx :bindings assoc (with-meta '*in*
(when-not stream? {:sci/deref! true})) in)]