Fork me on GitHub
#babashka
<
2021-02-08
>
maxp05:02:35

how to (prn ...) to stderr in babashka script?

lispyclouds05:02:29

This should work?

(binding [*out* *err*] (prn {:a "1" :b 2}))

maxp05:02:47

Thank you. I've tried System/err before - and that did not work %) `*err*` binding is ok.

borkdude09:02:30

@U0666UM3J Not sure what your problem with System/err was, but this works as well:

user=> (binding [*out* (io/writer System/err)] (println :err))
:err

maxp03:02:04

I've missed io/writer

borkdude10:02:18

wow ... 🀯

jeroenvandijk10:02:35

Happy birthday @borkdude πŸ™‚ πŸŽ‰

πŸŽ‰ 21
hyper-clap 8
πŸŽ‚ 9
Eccentric J11:02:56

Happy Birthday πŸŽ‰ πŸŽ‚

borkdude11:02:35

Thanks @U8WFYMFRU and thanks for your blog post gift!

🎁 1
kwrooijen11:02:15

Happy birthday! babashka

babashka 1
wilkerlucio13:02:47

happy birthday! πŸŽ‚

πŸŽ‰ 1
Pradeep B15:02:02

Happy Birthday @borkdude have a good one. πŸŽ‚ πŸŽ‰

❀️ 1
Mno17:02:01

Omg Happy Borkthday!

πŸ˜† 1
Mno17:02:30

May the babushkas shower you with gifts that spark kondo-esque joy. Hope you carve a big chunk of happiness that's sci-entifically incalculable.

babashka 1
lread19:02:01

Happy birthday! May your borktitude continue to flourish!

πŸ‘ 3
borkdude18:02:19

I missed this blog post when it came out almost a year ago: Deploy babashka script to AWS Lambda by @dainius.jocas https://www.jocas.lt/blog/post/babashka-aws-lambda/

lukasz18:02:05

@borkdude as you mentioned in the thread, this is way easier now that Lambda supports Docker images

πŸ‘ 2
lukasz18:02:22

layers were always a weird thing, clearly their (AWS) way of doing things

grazfather22:02:19

Actually, x-posting here since it’s relevant, and they even mention babashka https://clojurians.slack.com/archives/C03S1KBA2/p1612814934358300

grazfather22:02:45

In particular I like the idea of adding a reader macro to bb to make it extra easy to write a bash lines

borkdude22:02:03

@grazfather try:

user=> (require '[babashka.process :refer [$]])
nil
user=> ^{:inherit true} ($ ls -la)

grazfather22:02:53

what is the ^ {} part?

borkdude22:02:49

$ is a fancy macro to make it look like you're writing some shell invocation, it's part of the babashka.process lib: https://github.com/babashka/babashka.process The ^{..} part controls what to do with the output of the process. E.g. when you want to have a string:

(-> ^{:out :string} ($ ls -la) deref :out)

borkdude22:02:15

it's clojure metadata so you don't have to provide options inside the $ expression. the normal functional invocation would look like:

(-> (process ["ls" "-la"] {:out :string}) deref :out)

borkdude22:02:03

The $ macro also supports interpolation:

(let [dir "src"] (-> ^{:out :string} ($ ls -la ~dir) deref :out))