Fork me on GitHub
#babashka
<
2023-03-11
>
borkdude11:03:18

Recommended listen if you want to know more about @rahul080327, the "behind the scenes" of babashka's development and the contents of the coming workshop at https://clojure.stream!

👀 1
1
Peter Tonner19:03:55

is there are way to play nicely with command line tools that modify the shell with source ? Unless I'm totally missing something, this doesn't seem to work for me. My specific use case is SDKMAN, which requires a source "$HOME/.sdkman/bin/sdkman-init.sh" in your shell config to work. This, among many things, defines an sdk shell function for use on the command line. But when I try say bb -e "(require '[babashka.process :refer [shell]]) (shell \"sdk help\")" I get an error saying "Cannot run program 'sdk'". This is despite the fact that I can run sdk help directly in the same shell no problem. I also am not able to do bb -e "(require '[babashka.process :refer [shell]]) (shell \"source /path/to/.sdkman/src/sdkman-main.sh\")", instead receving an error "Cannot run program 'source'"

borkdude19:03:52

source is a built-in shell command, so you should do something like:

(shell (System/getenv "SHELL") "-c" "source" ...)

Peter Tonner19:03:15

got, I'll try that!

borkdude19:03:19

If sdk is function you should do the same

borkdude19:03:34

shell only runs binaries on your system, it actually doesn't use a shell ;)

borkdude19:03:50

it's only called like that because of the term "shelling out"

Peter Tonner19:03:11

oh okay, that makes sense - will definitely add that shell-calling pattern to my codebase somewhere I think I'll need it a lot. and calling sdk works now, thanks!

👍 1
pesterhazy21:03:28

Development question: How do I try out bb code from lein repl? Is this the recommended way?

(babashka.main/main "-e" "(prn :foo)")

borkdude21:03:14

or from the command line:

clj -M:babashka/dev -e '(prn :foo)' 

👍 1
borkdude21:03:31

where babashka/dev is a local/root dependency with :main-opts ["-m" "babashka.main"]

borkdude21:03:48

I usually use clj for local development