This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-11-08
Channels
- # announcements (8)
- # babashka (11)
- # beginners (63)
- # calva (1)
- # chlorine-clover (1)
- # cider (18)
- # cljfx (4)
- # cljs-dev (18)
- # clojure (17)
- # clojure-europe (20)
- # clojure-spec (2)
- # conjure (2)
- # data-science (6)
- # datomic (7)
- # depstar (17)
- # etaoin (2)
- # events (2)
- # fulcro (28)
- # graalvm (2)
- # graphql (3)
- # jobs-discuss (5)
- # off-topic (18)
- # pedestal (5)
- # reagent (6)
- # reveal (2)
- # shadow-cljs (39)
- # spacemacs (7)
- # xtdb (13)
I made a babashka survey: https://nl.surveymonkey.com/r/H2HK3RC Please fill it out if you have feedback for babashka!
I put set -e
at the top of a lot of my Bash scripts, so that all child processes that are synchronously run get implicitly checked for non-zero exit status. I'm wondering how I can get the same experience with Babashka. Maybe write a macro ($$ ...)
that's like babashka.process/$
but also adds an implicit (check ...)
?
user=> (defmacro $$ [& args] `(p/check (p/$ ~@args)))
#'user/$$
user=> (-> ($$ ls -la) :out slurp)
...
user=> (-> ($$ ls foo) :out slurp)
ls: foo: No such file or directory
Yeah that's pretty cool. I guess ^{:inherit true}
on the ($ ...)
too for the full experience?
Do you have the sense that many users write (or want to write) a bunch of straight-line code like (process ...)\n(process ...)\n(process ...)
or ($ ...)\n($ ...)\n($ ...)
?
If you don't need the output in your script, but you just want to do a side effect, then this could work yes:
user=> (defmacro $$ [& args] `(let [proc ^{:inherit true} (p/$ ~@args)] (p/check proc) nil))
#'user/$$
user=> ($$ ls README.md)
README.md
nil
user=> ($$ ls foo)
ls: foo: No such file or directory
[at <repl>:23:1]
I don't know about babashka, but this is pretty wide-spread in bash scripts: do one thing after another by starting a new process
Thanks! Yeah, as a Bash replacement it's good to be able to do that kind of straight line code in scripts without typing much
I have started a survey: https://nl.surveymonkey.com/r/H2HK3RC and from the responses I got there shelling out seems pretty common