diff --git a/CHANGELOG.md b/CHANGELOG.md index 13e87948..473540ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,16 @@ A preview of the next release can be installed from [Babashka](https://github.com/babashka/babashka): Native, fast starting Clojure interpreter for scripting +## Unreleased + +- Implement `ns`, `lazy-seq` as macro +- Support `--dev-build` flag in installation script +- [#1451](https://github.com/babashka/babashka/issues/1451): Allow passing explicit file and line number to clojure.test ([@matthewdowney](https://github.com/matthewdowney)) +- [#1280](https://github.com/babashka/babashka/issues/1280): babashka REPL doesn't quit right after Ctrl-d ([@formerly-a-trickster](https://github.com/formerly-a-trickster) and Alice Margatroid) +- [#1446](https://github.com/babashka/babashka/issues/1446): add `pprint/code-dispatch` +- Update zlib to version `1.2.13` ([@thiagokokada](https://github.com/thiagokokada)) +- [#1454](https://github.com/babashka/babashka/issues/1454): Add `babashka.process` to `print-deps` output + ## 1.0.168 (2022-12-07) - `loop*`, `fn*` are now special forms and `loop`, `fn`, `defn`, `defmacro`, `and` and `or` are implemented as macros. This restores compatibility with [rcf](https://github.com/borkdude/hyperfiddle-rcf) diff --git a/Dockerfile b/Dockerfile index 573142ce..f9ad88b3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,8 +7,9 @@ WORKDIR "/opt" ENV GRAALVM_VERSION="22.3.0" ARG TARGETARCH -ENV BABASHKA_ARCH=${TARGETARCH} -ENV GRAALVM_ARCH=${TARGETARCH} +# Do not set those directly, use TARGETARCH instead +ENV BABASHKA_ARCH= +ENV GRAALVM_ARCH= RUN if [ "${TARGETARCH}" = "" ] || [ "${TARGETARCH}" = "amd64" ]; then \ export GRAALVM_ARCH=amd64; export BABASHKA_ARCH=x86_64; \ elif [ "${TARGETARCH}" = "arm64" ]; then \ diff --git a/README.md b/README.md index 92cf4c2d..75a23601 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ anywhere on the path. Then you're ready to go: ``` shellsession -$ ls | bb -i '(filter #(-> % io/file .isDirectory) *input*)' +$ ls | bb -i '(filter fs/directory? *input*)' ("doc" "resources" "sci" "script" "src" "target" "test") bb took 4ms. ``` @@ -109,7 +109,8 @@ $ bb '(vec (dedupe *input*))' <<< '[1 1 1 1 2]' [1 2] ``` -Read more about input and output flags [here](https://book.babashka.org/#_input_and_output_flags). +Read more about `*input*` and in- and output flags +[here](https://book.babashka.org/#_input_and_output_flags). Execute a script. E.g. print the current time in California using the `java.time` API: @@ -174,6 +175,12 @@ Upgrade: You can find more documentation on how to use babashka with nix [here](./doc/nix.md). +### Alpine + +On Alpine it's recommended to download the binary manually from [Github +Releases](https://github.com/babashka/babashka/releases) and use the static +linux binary. + ### Arch (Linux) `babashka` is [available](https://aur.archlinux.org/packages/babashka-bin/) in the [Arch User Repository](https://aur.archlinux.org). It can be installed using your favorite [AUR](https://aur.archlinux.org) helper such as @@ -224,7 +231,7 @@ $ ./install --static ### Installer script -Install via the installer script: +Install via the installer script for linux and macOS: ``` shell $ curl -sLO https://raw.githubusercontent.com/babashka/babashka/master/install @@ -399,6 +406,8 @@ handling of SIGINT and SIGPIPE. This can be done by setting ## Articles, podcasts and videos +- [Babashka: How GraalVM Helped Create a Fast-Starting Scripting Environment for Clojure](https://medium.com/graalvm/babashka-how-graalvm-helped-create-a-fast-starting-scripting-environment-for-clojure-b0fcc38b0746) by Michiel Borkent +- [Adding Prompts To Your Babashka Scripts With Dialog](https://www.pixelated-noise.com/blog/2022/12/09/dialog-and-babashka/index.html) by A.C. Danvers - [Using Babashka to Get Electricity Prices](https://www.karimarttila.fi/clojure/2022/12/04/using-babashka-to-get-electricity-prices.html) by Kari Marttila - [Manage git hooks with babashka tasks](https://blaster.ai/blog/posts/manage-git-hooks-w-babashka.html) by Mykhaylo Bilyanskyy - [Messing around with babashka](https://ian-muge.medium.com/messing-around-with-babashka-f181a9003faa) by Ian Muge diff --git a/deps.clj b/deps.clj index a195e410..2d185718 160000 --- a/deps.clj +++ b/deps.clj @@ -1 +1 @@ -Subproject commit a195e410bfd61b3befcab40915cf6c2e54b0b7ca +Subproject commit 2d185718ba2871c96e6cb4a4181d1dcf9d8fde86 diff --git a/deps.edn b/deps.edn index 4e875585..692d7724 100644 --- a/deps.edn +++ b/deps.edn @@ -50,7 +50,7 @@ org.clojure/data.priority-map {:mvn/version "1.1.0"} insn/insn {:mvn/version "0.5.2"} org.clojure/core.rrb-vector {:mvn/version "0.1.2"} - org.babashka/cli {:mvn/version "0.5.40"}} + org.babashka/cli {:mvn/version "0.6.41"}} :aliases {:babashka/dev {:main-opts ["-m" "babashka.main"]} :profile diff --git a/fs b/fs index 965ca67e..d3226ccc 160000 --- a/fs +++ b/fs @@ -1 +1 @@ -Subproject commit 965ca67eb1b1ef26c412fa494ce31268fd456c8e +Subproject commit d3226cccd9898eba5adb50dfcc30a7223ff5c8cc diff --git a/install b/install index cb680842..349405b0 100755 --- a/install +++ b/install @@ -8,6 +8,7 @@ static_binary="false" default_install_dir="/usr/local/bin" install_dir="$default_install_dir" download_dir="" +dev_build="" print_help() { echo "Installs latest (or specific) version of babashka. Installation directory defaults to /usr/local/bin." @@ -56,6 +57,10 @@ do static_binary="true" shift ;; + --dev-build) + dev_build="true" + shift + ;; *) # unknown option print_help shift @@ -74,7 +79,11 @@ if [[ "$checksum" != "" ]] && [[ "$version" == "" ]]; then fi if [[ "$version" == "" ]]; then - version="$(curl -sL https://raw.githubusercontent.com/babashka/babashka/master/resources/BABASHKA_RELEASED_VERSION)" + if [[ "$dev_build" == "true" ]]; then + version="$(curl -sL https://raw.githubusercontent.com/babashka/babashka/master/resources/BABASHKA_VERSION)" + else + version="$(curl -sL https://raw.githubusercontent.com/babashka/babashka/master/resources/BABASHKA_RELEASED_VERSION)" + fi fi case "$(uname -s)" in @@ -94,7 +103,12 @@ case "$(uname -m)" in arch="aarch64" fi ;; - *) arch=amd64;; + *) arch=amd64 + # always use static image on linux + if [[ "$platform" == "linux" ]]; then + static_binary="true" + fi + ;; esac if [[ 10#$vernum -le 10#000002013 ]]; then diff --git a/process b/process index 9e19562e..90e4cf0b 160000 --- a/process +++ b/process @@ -1 +1 @@ -Subproject commit 9e19562e108381be7bced275a9065dc182ec1c62 +Subproject commit 90e4cf0b0cc7856f8c39591c3350cdf156d11042 diff --git a/project.clj b/project.clj index 106731db..f5794d71 100644 --- a/project.clj +++ b/project.clj @@ -32,7 +32,7 @@ [com.github.clj-easy/graal-build-time "0.1.0"] [rewrite-clj/rewrite-clj "1.1.45"] [insn/insn "0.5.2"] - [org.babashka/cli "0.5.40"]] + [org.babashka/cli "0.6.41"]] :plugins [[org.kipz/lein-meta-bom "0.1.1"]] :metabom {:jar-name "metabom.jar"} :profiles {:feature/xml {:source-paths ["feature-xml"] diff --git a/resources/META-INF/babashka/deps.edn b/resources/META-INF/babashka/deps.edn index 4e875585..692d7724 100644 --- a/resources/META-INF/babashka/deps.edn +++ b/resources/META-INF/babashka/deps.edn @@ -50,7 +50,7 @@ org.clojure/data.priority-map {:mvn/version "1.1.0"} insn/insn {:mvn/version "0.5.2"} org.clojure/core.rrb-vector {:mvn/version "0.1.2"} - org.babashka/cli {:mvn/version "0.5.40"}} + org.babashka/cli {:mvn/version "0.6.41"}} :aliases {:babashka/dev {:main-opts ["-m" "babashka.main"]} :profile diff --git a/sci b/sci index 62a16eb6..92a07126 160000 --- a/sci +++ b/sci @@ -1 +1 @@ -Subproject commit 62a16eb620bb6e8ae072f9f17baa3de5546f0902 +Subproject commit 92a071269f1a4e3f4fda262b33b47ec827be3d4e diff --git a/script/setup-musl b/script/setup-musl index ad055064..dcb552e5 100755 --- a/script/setup-musl +++ b/script/setup-musl @@ -19,8 +19,8 @@ fi apt-get update -y && apt-get install musl-tools -y -ZLIB_VERSION="1.2.11" -ZLIB_SHA256="c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1" +ZLIB_VERSION="1.2.13" +ZLIB_SHA256="b3a24de97a8fdbc835b9833169501030b8977031bcb54b3b3ac13740f846ab30" # stable archive path curl -O -sL --fail --show-error "https://zlib.net/fossils/zlib-${ZLIB_VERSION}.tar.gz" diff --git a/src/babashka/impl/classes.clj b/src/babashka/impl/classes.clj index 0cafceee..525bd54d 100644 --- a/src/babashka/impl/classes.clj +++ b/src/babashka/impl/classes.clj @@ -120,7 +120,8 @@ clojure.lang.APersistentVector {:methods [{:name "indexOf"}]} clojure.lang.LazySeq - {:methods [{:name "indexOf"}]} + {:allPublicConstructors true, + :methods [{:name "indexOf"}]} clojure.lang.ILookup {:methods [{:name "valAt"}]} clojure.lang.IPersistentMap diff --git a/src/babashka/impl/clojure/test.clj b/src/babashka/impl/clojure/test.clj index 422947a2..8903e911 100644 --- a/src/babashka/impl/clojure/test.clj +++ b/src/babashka/impl/clojure/test.clj @@ -297,7 +297,7 @@ current assertion." {:added "1.1"} [m] - (let [{:keys [:file :line]} (meta (first @testing-vars))] + (let [{:keys [:file :line]} (merge m (meta (first @testing-vars)))] (str ;; Uncomment to include namespace in failure report: ;;(ns-name (:ns (meta (first *testing-vars*)))) "/ " diff --git a/src/babashka/impl/pprint.clj b/src/babashka/impl/pprint.clj index 0c0e815f..88ada2e6 100644 --- a/src/babashka/impl/pprint.clj +++ b/src/babashka/impl/pprint.clj @@ -208,6 +208,7 @@ 'init-navigator (sci/copy-var pprint/init-navigator pprint-ns) 'execute-format (sci/copy-var execute-format pprint-ns) 'with-pprint-dispatch (sci/copy-var pprint/with-pprint-dispatch pprint-ns) + 'code-dispatch (sci/copy-var pprint/code-dispatch pprint-ns) '*print-pprint-dispatch* print-pprint-dispatch '*print-miser-width* print-miser-width 'get-pretty-writer (sci/copy-var get-pretty-writer pprint-ns) diff --git a/src/babashka/impl/print_deps.clj b/src/babashka/impl/print_deps.clj index 45e2b3f8..0e9d0288 100644 --- a/src/babashka/impl/print_deps.clj +++ b/src/babashka/impl/print_deps.clj @@ -14,10 +14,11 @@ edn/read-string) deps (:deps deps) deps (assoc deps - 'babashka/fs {:mvn/version "0.1.2"} - 'babashka/babashka.curl {:mvn/version "0.1.1"} + 'babashka/fs {:mvn/version "0.2.12"} + 'babashka/babashka.curl {:mvn/version "0.1.2"} 'babashka/babashka.core {:git/url "https://github.com/babashka/babashka.core" - :git/sha "52a6037bd4b632bffffb04394fb4efd0cdab6b1e"}) + :git/sha "52a6037bd4b632bffffb04394fb4efd0cdab6b1e"} + 'babashka/process {:mvn/version "0.4.13"}) deps (dissoc deps 'borkdude/sci 'org.babashka/sci diff --git a/src/babashka/impl/repl.clj b/src/babashka/impl/repl.clj index e1083b5b..11dcf370 100644 --- a/src/babashka/impl/repl.clj +++ b/src/babashka/impl/repl.clj @@ -63,13 +63,14 @@ (eval-form sci-ctx `(apply require (quote ~m/repl-requires))))) :read (or read (fn [_request-prompt request-exit] - (let [v (parser/parse-next sci-ctx in)] - (skip-if-eol in) - (if (or (identical? :repl/quit v) - (identical? :repl/exit v) - (identical? parser/eof v)) - request-exit - v)))) + (if (nil? (r/peek-char in)) + request-exit + (let [v (parser/parse-next sci-ctx in)] + (skip-if-eol in) + (if (or (identical? :repl/quit v) + (identical? :repl/exit v)) + request-exit + v))))) :eval (or eval (fn [expr] (sci/with-bindings {sci/file "" diff --git a/test/babashka/test_test.clj b/test/babashka/test_test.clj index 08a58249..b0ad6da5 100644 --- a/test/babashka/test_test.clj +++ b/test/babashka/test_test.clj @@ -112,3 +112,9 @@ (deftest line-number-test (is (str/includes? (bb "test-resources/line_number_test_test.clj") "line_number_test_test.clj:4"))) + +(deftest testing-vars-str-test + (is (str/includes? + (bb "(clojure.test/testing-vars-str {:file \"x\" :line 1})") + "() (x:1)") + "includes explicit line number + file name in test report"))