Fork me on GitHub

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!

👀 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/" 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/\")", instead receving an error "Cannot run program 'source'"


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!


If sdk is function you should do the same


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


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

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

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


or from the command line:

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

👍 1

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


I usually use clj for local development