Fork me on GitHub
#babashka
<
2021-11-24
>
borkdude16:11:38

I wonder if bb should add some things from clojure 1.11 already. Since it's alpha there is a risk of breaking changes.

mynomoto16:11:52

bb-alpha? 😅

heow16:11:32

I would love to see how "infinite?" is implemented in a discrete amount of time.

heow16:11:58

bah, just a "dumb wrapper"

😆 1
thompen21:11:44

If I'm launching a UI application, is there a way for me to avoid having it killed in case I have to kill the script? (process/process ["gedit"]) (-> (async/alts!! [(async/thread (loop [] (Thread/sleep 1000) (recur)))])) I also tried running with nohup and other methods.

borkdude21:11:12

@thomascpendergrast use (process/process ["gedit"] {:shutdown process/destroy-tree})

borkdude21:11:31

oh, you want to avoid killing it

borkdude21:11:02

btw, you can use @(promise) instead of the core.async stuff to hang the script

borkdude21:11:50

process/process doesn't actively kill child processes, nor does Java I think, but perhaps gedit checks if the parent process is still alive and then kills itself? I don't know

borkdude21:11:45

@thomascpendergrast you can use ["open" "gedit"] probably to keep running gedit after the script has finished running

borkdude21:11:58

or the linux equivalent of this

thompen21:11:32

hmm.. that works with a filename, not a program. but it gets killed anyway if I use ["xdg-open" "1.txt"] I also tried with ["xdg-open" "1.txt" "&"] but I guess that doesn't work from babashka.process (I'm getting unexpected argument '$', if I read the error stream)

thompen21:11:13

the weird thing is that even if I try regular bash scripts that I use to make sure a launched program isn't terminated if the terminal is killed, it still gets killed if invoked from babashka

thompen21:11:33

hmm... found something that works ["/usr/bin/zsh" "-c" "gedit &"]

borkdude22:11:48

cool yeah, you can also use (System/getenv "SHELL") to get your default shell

👍 1
thompen22:11:43

another unrelated question, how can I invoke a function from something on the classpath. Similar to the classpath examples in the docs, but no with --main just a regular script or with -e. I tried adding another function to a set-up like the example but: bb --classpath scripts -e '(my.namespace/foo)' fails with: Could not resolve symbol: my.namespace/foo

borkdude22:11:03

@thomascpendergrast you first have to require a namespace before it gets loaded. but actually you can run a function with -m this way too: -m my.namespace/foo

borkdude22:11:47

-m my.namespace/foo is basically -e "(do (require 'my.namespace) (apply my.namespace/foo *command-line-args*)"

thompen22:11:37

awesome! thanks