Fork me on GitHub

The key thing with exec is that it replaces your process


Yes, I guess you can't do that with babashka, but ProcessBuilder + inheritIO + System/exit the exit code of that process is the closest thing that comes next probably

Johannes F. Knauf14:07:27

I believe this will be hard to do in a portable way, won't it? bash relies on system call to perform the trick. How would that work in Windows?


ProcessBuilder fulfils this role well enough functionally, although it's not technically the same. So I think we don't need anything new.


I've been playing with babashka, and one initial puzzle for me was the printing behaviour

% bb '(:a {:a 3})'
% bb '(:b {:a 3})'
Is this described in the docs somewhere that i missed, or too obvious to mention? It took my stupid brain a while to work out what was going on


so a final nil value doesnt seem to be printed


@grahamcarlyle nil is not printed. This is because lots of side effects return nil, e.g. (println :foo) and a lot of scripts end in something side-effecting


So if you really want to print the nil, you can use (prn ..) instead


yeah it makes sense, but i didnt realise this behaviour initially and so was puzzled by the absence or presence of output


I guess it's not properly documented.


Feel free to make a documentation PR if you wish so

👍 3

i've created a PR for this, hope i created it ok.


Thanks, merged


is there a way of controlling the input/output processing behaviour of bb within a script? so the things that the -o/-O flags would change, i wondered if there was a function i could call to alter the behaviour. My use was a script that in some cases wanted to output text and in other cases EDN.


In that case I think it's better to just use println and prn. The flags are mostly there for one-liners.

👍 3

i guess another utility of being able to set the flags in a script is when a script could be called via shebang style or as a script


as the flags would be in 1 place


Script from work where we start 2 clojure processes (for building CLJS and less) and 1 boot process (for a JVM Clojure process / REPL) using 1 babashka script: The alternative was to have 3 different tabs open

👍 6
🚀 3