diff --git a/project.clj b/project.clj index 610be98b..b21a0f29 100644 --- a/project.clj +++ b/project.clj @@ -7,12 +7,11 @@ :url "https://github.com/borkdude/babashka"} :license {:name "Eclipse Public License 1.0" :url "http://opensource.org/licenses/eclipse-1.0.php"} - :java-source-paths ["sci/src-java"] :source-paths ["src" "sci/src"] :resource-paths ["resources" "sci/resources"] :dependencies [[org.clojure/clojure "1.10.1"] [org.clojure/tools.reader "1.3.2"] - [borkdude/edamame "0.0.8-alpha.2"] + [borkdude/edamame "0.0.8-alpha.3"] [org.clojure/core.async "0.4.500"] [org.clojure/tools.cli "0.4.2"]] :profiles {:test {:dependencies [[clj-commons/conch "0.9.2"]]} diff --git a/sci b/sci index f7487133..52ed6f4f 160000 --- a/sci +++ b/sci @@ -1 +1 @@ -Subproject commit f7487133fb6ba44be8f9cb38416550a2923b6217 +Subproject commit 52ed6f4f9885d3a28b007ccf2e116d8270f35f4b diff --git a/src/babashka/impl/socket_repl.clj b/src/babashka/impl/socket_repl.clj index b4fe4d82..6f021c38 100644 --- a/src/babashka/impl/socket_repl.clj +++ b/src/babashka/impl/socket_repl.clj @@ -32,12 +32,15 @@ v)) request-exit)) :eval (fn [expr] - (let [ret (eval-edn-vals (update-in sci-ctx - [:namespaces 'clojure.core] - merge {'*1 *1 - '*2 *2 - '*3 *3 - '*e *e}) + (let [ret (eval-edn-vals (update sci-ctx + :env + (fn [env] + (swap! env assoc + '*1 *1 + '*2 *2 + '*3 *3 + '*e *e) + env)) [expr])] ret)) :need-prompt (fn [] true)))) diff --git a/test/babashka/impl/socket_repl_test.clj b/test/babashka/impl/socket_repl_test.clj index 108ac299..f00a0179 100644 --- a/test/babashka/impl/socket_repl_test.clj +++ b/test/babashka/impl/socket_repl_test.clj @@ -12,9 +12,10 @@ "mac")) (defn socket-command [expr] - (let [ret (sh "bash" "-c" - (format "echo \"%s\n:repl/exit\" | nc 127.0.0.1 1666" - (pr-str expr)))] + (let [expr (format "echo \"%s\n:repl/exit\" | nc 127.0.0.1 1666" + (pr-str expr)) + ret (sh "bash" "-c" + expr)] (:out ret))) (deftest socket-repl-test @@ -59,6 +60,11 @@ "#?(:bb 1337 :clj 8888)"))] (:out ret)) "1337"))) + (testing "*1, *2, *3, *e" + (is (= 2 (count (re-seq #"1\n" (let [ret (sh "bash" "-c" + (format "echo \"%s\n*1\n:repl/exit\" | nc 127.0.0.1 1666" + "1"))] + (:out ret))))))) (finally (if tu/jvm? (stop-repl!) diff --git a/test/babashka/main_test.clj b/test/babashka/main_test.clj index 98d5215f..4169b17b 100644 --- a/test/babashka/main_test.clj +++ b/test/babashka/main_test.clj @@ -224,4 +224,5 @@ (is (zero? (bb nil "(try (/ 1 0) (catch ArithmeticException _ 0))")))) (deftest reader-conditionals-test - (is (= :hello (bb nil "#?(:clj (in-ns 'foo)) (println :hello)")))) + (is (= :hello (bb nil "#?(:clj (in-ns 'foo)) (println :hello)"))) + (is (= :hello (bb nil "#?(:bb :hello :default :bye)"))))