Native, fast starting Clojure interpreter for scripting
EPL-1.0 License
Bot releases are hidden (Show)
sun.net.www.protocol.http.HttpURLConnection
to reflection config to make http://
(not https://
) calls working with https://github.com/borkdude/clj-http-lite.:refer-clojure
+ :exclude
in ns formcondp
defn-
instance?
delay
java.nio.file.Paths
require
can now be used with a single symbol instead of a sequential collection*file*
. See https://github.com/borkdude/babashka/#current-file-path.letfn
*in*
to <input>
(in the user
namespace). The name was a poor choice for two reasons. It shadowed clojure.core/*in*
. Also, the value was not a dynamic var, but the earmuffs suggested otherwise.clojure.edn/read
clojure.string/re-quote-replacement
java.time
API. This is an example how you can print the current time in California:#!/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))
#160: Add support for java.lang.ProcessBuilder
. See docs. This replaces the conch
namespace (BREAKING).
#162: Add support for java.util.Base64
:
$ bb '(String. (.decode (java.util.Base64/getDecoder) "YmFiYXNoa2E="))'
"babashka"
java.lang.Math
:$ bb '(Math/pow 2 3)'
8.0
Support for --classpath / -cp
, BABASHKA_CLASSPATH
and --main / -m
.
Read more about it here:
cheshire.core
namespace is available via the json
alias in the user
namespace:$ bb '(println (json/encode {:a 1}))'
{"a":1}
$ bb "(require '[cheshire.core :as cheshire]) (cheshire/generate-string {:a 1})"
"{\"a\":1}"
--repl
. Using rlwrap
is recommended.$ rlwrap bb
Babashka v0.0.39 REPL.
Use :repl/quit or :repl/exit to quit the REPL.
Clojure rocks, Bash reaches.
user=> (+ 1 2 3)
6
$ bb '(def ^:dynamic *x* 1) (binding [*x* 10] (prn *x*)) (prn *x*)'
10
1
java.nio.file.attribute
classes (thanks @holyjak)Includes fix for https://github.com/borkdude/edamame/issues/34
Upgrade to GraalVM 19.3.0. This means that SSL now works without any additional configuration due to static linking of the necessary library:
$ bb '(-> (slurp "https://www.clojure.org") (subs 0 55))'
"<!DOCTYPE html>\n<!-- This site was created in Webflow. "
Fix for sci issue: https://github.com/borkdude/sci/issues/156
binding
, with-out-str
and with-in-str
:$ ./bb '(let [w (java.io.StringWriter.)] (binding [*out* w] (println "hello")) (str w))'
"hello\n"
$ ./bb "(count (with-out-str (println \"hello\")))"
6
$ ./bb '(with-in-str "hi" (read-line))'
"hi"
Notes:
binding
only works with clojure.core/*in*
and clojure.core/*out*
*in*
has a special meaning in babashka expressions, but you can refer to Clojure's *in*
by fully qualifying it: clojure.core/*in*
.