This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-01-16
Channels
- # announcements (2)
- # babashka (51)
- # beginners (165)
- # biff (39)
- # clara (1)
- # clj-kondo (20)
- # cljsrn (6)
- # clojure (64)
- # clojure-belgium (11)
- # clojure-conj (2)
- # clojure-europe (12)
- # clojure-nl (3)
- # clojure-norway (7)
- # clojure-uk (6)
- # clojurescript (11)
- # conf-proposals (1)
- # conjure (1)
- # core-async (19)
- # cursive (6)
- # data-science (16)
- # datomic (6)
- # deps-new (4)
- # fulcro (60)
- # funcool (3)
- # graalvm (9)
- # helix (14)
- # introduce-yourself (4)
- # jobs-discuss (13)
- # joyride (1)
- # kaocha (2)
- # malli (12)
- # off-topic (25)
- # polylith (9)
- # portal (3)
- # practicalli (1)
- # rdf (43)
- # re-frame (7)
- # reagent (5)
- # releases (5)
- # remote-jobs (8)
- # sci (5)
- # shadow-cljs (42)
- # squint (6)
- # xtdb (5)
Do people write TUI apps with Babashka? If so, what are the relevant libs to do so?
I've done some experiments with lanterna: https://twitter.com/borkdude/status/1569351199404576770 It worked pretty well, but I don't consider the pod stable. You can play around with it locally though and see how far you get. But if you want some simple dialogs, then this may be a nice approach: https://www.pixelated-noise.com/blog/2022/12/09/dialog-and-babashka/index.html Node.js / #nbb might give you better options using something like reagent and Ink: https://github.com/babashka/nbb#reagent
you can obtain (exerimental) binaries for pod-babashka-lanterna here from the builds: https://app.circleci.com/pipelines/github/babashka/pod-babashka-lanterna and then play around with it - docs are here: https://github.com/babashka/pod-babashka-lanterna
This could work too https://www.pixelated-noise.com/blog/2022/12/09/dialog-and-babashka/index.html
@U04V15CAJ thanks for sharing!
Is the *warn-on-reflection*
var meaningful in babashka scripts? I am asking because clj-kondo will lint a babashka file (ending in .clj
though) and complain about using (System/exit 1)
without a warn-on-reflection set...
This can take so many directions:
• Should accessing static functions on a namespace such System/exit
trigger the reflection warning?
• Does kondo have different linters for babashka files?
• Should babashka files have a .clj
extension?
(Our babashka file uses clj-kondo as a pod so it's definitely bb only)
This is an optional linter. You can set warn-on-reflection in babashka, but it has no effect. You can use the .bb
extension as well if you want
We have it on inside our .clj-kondo/config.edn
, since we do care about it in production.
Hm, how would we define an additional config only for babashka scripts? So e.g. src
and test
get linted with one config, then bin
gets linted with something else?
I'd say, just go with the *warn-on-reflection*
in your bb script, even though it has no effect, it's at least consistent with the rest of your code
Is it possible to spawn child processes and disown them in babashka? I'm trying to write some convenience wrappers around a bunch of bash scripts, but a number of them spawn background child tasks. Trying to run those scripts through babashka will result in those child processes being killed when the task is done. Ex.
# test.sh
sleep 5
echo "HERE"
# test2.sh
./test.sh &
If I run test2.sh
in a terminal, then the script will finish, drop me back into my prompt, and then I'll get interupted with that "HERE"
in 5 seconds. If I do
;; bb.edn
{:tasks
{:requires ([babashka.process :as ps])
test (ps/process "./test2.sh")}}
And then run bb test
, I'll just never see that HERE
printed cause the child background process is killedSorry, I sent that before I meant to, I've edited to include more information. I'm using the process library
e.g. this works for me:
bb -e '(babashka.process/process {:inherit true} "/tmp/sleep.sh")'
Hmm. I have this task with exactly those bash scripts above, and it's not doing anything
bg (ps/process "./scripts/test2.sh &" {:inherit true})
Running bb bg
does nothing, I never get the echos from the bash scriptOh, removing the &
from the string there does nothing either, I just added that to try it
$ cat /tmp/sleep.sh
# test.sh
sleep 5
echo "HERE"
$ bb -e '(babashka.process/process {:inherit true} "/tmp/sleep.sh") nil'
$ HERE
Try this first. Don't forgot to chmod +x
the /tmp/sleep.sh
scriptHmm, that still doesn't work.
$ ./scripts/test2.sh
$ HERE
$ bb -e '(babashka.process/process {:inherit true} "./scripts/test2.sh") nil'
$
$
@U01BH40EA0Z Perhaps you can make a github repo so we are executing 100% the same code - I find it weird that we're both on a mac and we get different behavior. What's your bb version?
Are you on the latest babashka?
The opts-first syntax will silently fail on older versions
yeah, so let's make a repro so we're 100% sure about the code and also specify the bb version
@U04V15CAJ Here's a repo. I'm using babashka version v1.0.168 and MacOS 13.0.1
Oh lol, sorry, forgot to paste the link https://github.com/nixin72/testing
@U01BH40EA0Z This works perfectly over here:
$ bb tasks
The following tasks are available:
test
borkdude@m1 /tmp/testing (main) $ bb test
borkdude@m1 /tmp/testing (main) $ HERE
bb terminates and then HERE
is printed. Also tested with 1.0.168. My shell is zshCan you test from a vanilla bash shell?
$ bash
The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit .
bash-3.2$ bb test
bash-3.2$ HERE
Thank you so much as always @U04V15CAJ! I really appreciate it