Fork me on GitHub

I made a babashka survey: 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 ...) ?


yes, you could do that (or just a function)


user=> (defmacro $$ [& args] `(p/check (p/$ ~@args)))
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=> ($$ ls
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: and from the responses I got there shelling out seems pretty common

✍️ 6

That nice macro nudged me to put it in a file and start using BABASHKA_PRELOADS 😀

🎉 6