Fork me on GitHub
#babashka
<
2023-10-08
>
jasonjckn02:10:30

i'm trying to shell out to something that uses an ncurses-like library, but it's not rendering the text UI, e.g. (shell/sh "gum" "choose" "a" "b" "c")

Bob B03:10:59

afaik, that's essentially a limitation of sh - inheritting the IO streams should resolve that, but I don't think there's a trivial way to do so with clojure.java.shell/sh - with that said, babashka.process/shell does it by default

👍 1
Bob B03:10:06

and for gum specifically, <https://github.com/lispyclouds/bblgum> wraps the calls if you don't want to deal with the shell layer at all

🔥 1
jasonjckn04:10:24

exactly what I needed ty

jasonjckn04:10:04

This is much better than i thought it was going to be as a bash replacement, finally drank the kool-aid, 10 mins in i'm already more productive than a lifetime of bash scripting.

🎉 8
clojurian 2
babashka 3
❤️ 1
yes 1
jasonjckn06:10:25

my approximation of bash's set -x 🙃

borkdude07:10:58

You can also change babashka.process/*defaults* and change the :pre-start-fn to print the command, but alter-var-root also works :)

👍 1
jasonjckn06:10:10

is there a way to tell if you're in a nREPL env?

1
borkdude07:10:16

What problem are you solving?

jasonjckn08:10:52

trying to implement function die() with System/exit, but be able to test it in the nREPL session

jasonjckn08:10:41

I think i found an alright workaround for REPL development,

jasonjckn08:10:54

i'll just eval (defn abort [code] (throw (RuntimeException. "abort called"))) when i start a REPL session

borkdude09:10:41

@U0J3J79FE You can do (throw (ex-info "..." {:babashka/exit 1}))

🙌 1
borkdude09:10:49

the exit code will be picked up by babashka

borkdude09:10:56

and in the REPL it's just an exception

jasonjckn18:10:47

my pre-start-fn seems to only be called for p/shell, not p/exec, (either that or it's just not flushing the STDOUT in time for exec)

jasonjckn18:10:32

(alter-var-root #'p/*defaults* assoc :pre-start-fn (fn [{:keys [cmd]}]
                                                     (when *verbose?* (apply println "++" cmd) (flush))))

borkdude19:10:43

@U0J3J79FE which version of bb do you have installed?

jasonjckn19:10:48

i added (flush) after the println, still no good

jasonjckn19:10:54

i looked a little bit at your code for exec, it seems to call it

jasonjckn19:10:32

i can send a repro example if you want

borkdude19:10:46

yeah, I can repro it locally now, not sure why this is happening

👍 1
jasonjckn19:10:03

i don't think its being called

(alter-var-root #'p/*defaults* assoc :pre-start-fn (fn [{:keys [cmd]}]
                                                     (when *verbose?* (apply println "++" cmd)
                                                           (flush)
                                                           (Thread/sleep 10000))))

jasonjckn19:10:10

doesn't hang for exec, but does for shell

borkdude19:10:09

I'll add this and then compile:

_ (prn pre-start-fn)

👍 1
jasonjckn19:10:48

have to go for an appt in 5 mins, but i'll be back in ~2 hours, thanks for debugging this!

jasonjckn19:10:05

and thanks for your project in general

❤️ 1
borkdude19:10:24

I get what is wrong

🙌 1
borkdude19:10:29

I'll fix it

borkdude19:10:51

pushed a solution. once master finishes, you should be able to install the update with:

bash <(curl ) --dev-build --dir /tmp
and with that version it should work

jasonjckn19:10:17

ty ! i’ll try it out when i get back