Fork me on GitHub
#babashka
<
2020-11-08
>
borkdude10:11:39

I made a babashka survey: https://nl.surveymonkey.com/r/H2HK3RC Please fill it out if you have feedback for babashka!

holmdunc18:11:06

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 ...) ?

borkdude18:11:00

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

borkdude18:11:11

user=> (defmacro $$ [& args] `(p/check (p/$ [email protected])))
#'user/$$
user=> (-> ($$ ls -la) :out slurp)
...
user=> (-> ($$ ls foo) :out slurp)
ls: foo: No such file or directory

holmdunc18:11:49

Yeah that's pretty cool. I guess ^{:inherit true} on the ($ ...) too for the full experience?

holmdunc18:11:13

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($ ...) ?

borkdude18:11:26

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/$ [email protected])] (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]

borkdude18:11:41

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

holmdunc18:11:34

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

borkdude18:11:54

I have started a survey: https://nl.surveymonkey.com/r/H2HK3RC and from the responses I got there shelling out seems pretty common

✍️ 6
holmdunc19:11:00

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

🎉 6