diff --git a/.gitignore b/.gitignore index b5cf81da..893aeb51 100644 --- a/.gitignore +++ b/.gitignore @@ -38,3 +38,4 @@ target .DS_Store .portal default.iprof +scratch.clj diff --git a/CHANGELOG.md b/CHANGELOG.md index d7515fb7..420d6bc8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ A preview of the next release can be installed from ## Unreleased +- Upgrade Clojure to `1.12.0` +- [#1720](https://github.com/babashka/babashka/issues/1720): Include `clojure.java.process` - [#1598](https://github.com/babashka/babashka/issues/1598): use Rosetta on CircleCI to build x64 images - Bump SCI - Bump `fs` diff --git a/README.md b/README.md index 058d7fc2..f855706a 100644 --- a/README.md +++ b/README.md @@ -40,10 +40,10 @@ As one user described it: ## Quickstart For installation options check [Installation](https://github.com/babashka/babashka#installation). -For quick installation use: +For quick installation using `bash`, use: ``` shell -$ bash < <(curl -s https://raw.githubusercontent.com/babashka/babashka/master/install) +bash < <(curl -s https://raw.githubusercontent.com/babashka/babashka/master/install) ``` or grab a binary from [Github @@ -53,9 +53,12 @@ anywhere on the path. Then you're ready to go: ``` shellsession -$ ls | bb -i '(filter fs/directory? *input*)' -("doc" "resources" "sci" "script" "src" "target" "test") -bb took 4ms. +time bb -e '(->> (fs/list-dir ".") (filter fs/directory?) (map fs/normalize) (map str) (take 3))' +``` + +``` clojure +(".build" "feature-lanterna" ".repl") +bb -e 0,01s user 0,01s system 70% cpu 0,017 total ``` ## Support :heart: @@ -120,46 +123,6 @@ by Daniel Higginbotham, who has also helped a lot of people learn Clojure with [Clojure for the Brave and True](https://www.braveclojure.com/clojure-for-the-brave-and-true/). -## Examples - -Read the output from a shell command as a lazy seq of strings: - -``` shell -$ ls | bb -i '(take 2 *input*)' -("CHANGES.md" "Dockerfile") -``` - -Read EDN from stdin and write the result to stdout: - -``` shell -$ bb '(vec (dedupe *input*))' <<< '[1 1 1 1 2]' -[1 2] -``` - -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: - -File `pst.clj`: -``` clojure -#!/usr/bin/env bb - -(def now (java.time.ZonedDateTime/now)) -(def LA-timezone (java.time.ZoneId/of "America/Los_Angeles")) -(def LA-time (.withZoneSameInstant now LA-timezone)) -(def pattern (java.time.format.DateTimeFormatter/ofPattern "HH:mm")) -(println (.format LA-time pattern)) -``` - -``` shell -$ bb pst.clj -05:17 -``` - -More examples can be found [here](examples/README.md). - ## Try online You can try babashka online with Nextjournal's babashka [notebook diff --git a/deps.edn b/deps.edn index 2f3a49c4..6efcc2d1 100644 --- a/deps.edn +++ b/deps.edn @@ -18,7 +18,7 @@ "deps.clj/src" "deps.clj/resources" "resources" "sci/resources" "impl-java/src"], - :deps {org.clojure/clojure {:mvn/version "1.11.2"}, + :deps {org.clojure/clojure {:mvn/version "1.12.0"}, org.babashka/sci {:local/root "sci"} org.babashka/babashka.impl.java {:mvn/version "0.1.8"} org.babashka/sci.impl.types {:mvn/version "0.0.2"} diff --git a/fs b/fs index 11121ded..99d6a3b2 160000 --- a/fs +++ b/fs @@ -1 +1 @@ -Subproject commit 11121dedba416e93ce1eb69674c78f269a1f3e0a +Subproject commit 99d6a3b2f55b851a6949ed6eee31412b299dcf01 diff --git a/project.clj b/project.clj index 3754fa36..bc8a5e7e 100644 --- a/project.clj +++ b/project.clj @@ -21,8 +21,8 @@ :non-flaky (complement :flaky) :flaky :flaky} :jvm-opts ["--enable-preview"] - :dependencies [[org.clojure/clojure "1.11.2"] - [borkdude/edamame "1.4.24"] + :dependencies [[org.clojure/clojure "1.12.0"] + [borkdude/edamame "1.4.27"] [borkdude/graal.locking "0.0.2"] [org.clojure/tools.cli "1.0.214"] [cheshire "5.13.0"] diff --git a/sci b/sci index c556f447..f766255d 160000 --- a/sci +++ b/sci @@ -1 +1 @@ -Subproject commit c556f4474303c61da72e7a07eef496dcbf66a56e +Subproject commit f766255d14647d46486546dc6afce1ae1bcd2c7b diff --git a/src/babashka/impl/clojure/java/process.clj b/src/babashka/impl/clojure/java/process.clj new file mode 100644 index 00000000..f479affc --- /dev/null +++ b/src/babashka/impl/clojure/java/process.clj @@ -0,0 +1,6 @@ +(ns babashka.impl.clojure.java.process + (:require [clojure.java.process] + [sci.core :as sci])) + +(def cjp (sci/create-ns 'clojure.java.process nil)) +(def cjp-namespace (sci/copy-ns clojure.java.process cjp)) diff --git a/src/babashka/main.clj b/src/babashka/main.clj index 1a90c663..1b15e139 100644 --- a/src/babashka/main.clj +++ b/src/babashka/main.clj @@ -25,6 +25,7 @@ [babashka.impl.clojure.tools.reader-types :refer [edn-namespace reader-types-namespace]] [babashka.impl.clojure.zip :refer [zip-namespace]] + [babashka.impl.clojure.java.process :refer [cjp-namespace]] [babashka.impl.common :as common] [babashka.impl.core :as bbcore] [babashka.impl.curl :refer [curl-namespace]] @@ -389,6 +390,7 @@ Use bb run --help to show this help output. 'main main-var} 'clojure.test t/clojure-test-namespace 'clojure.math math-namespace + 'clojure.java.process cjp-namespace 'babashka.classpath classpath-namespace 'babashka.classes classes-namespace 'clojure.pprint pprint-namespace diff --git a/test/babashka/error_test.clj b/test/babashka/error_test.clj index e79967b3..d3230f75 100644 --- a/test/babashka/error_test.clj +++ b/test/babashka/error_test.clj @@ -11,7 +11,8 @@ (-> line str/trimr ;; take into account JDK14+ and native image differences (str/replace "class clojure.lang" "clojure.lang") - (str/replace #" \(.*\)$" ""))) + (str/replace #" \(.*\)$" "") + (str/replace #"--\d\d\d\d" ""))) (defmacro multiline-equals [s1 s2] `(let [lines-s1# (str/split-lines ~s1)