This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-09-09
Channels
- # announcements (10)
- # aws (7)
- # babashka (28)
- # babashka-sci-dev (53)
- # beginners (11)
- # clojure (43)
- # clojure-europe (100)
- # clojure-morsels (1)
- # clojure-nl (2)
- # clojure-norway (6)
- # clojure-russia (2)
- # clojure-spec (13)
- # clojure-uk (7)
- # clojurescript (13)
- # conjure (21)
- # datalevin (3)
- # emacs (46)
- # etaoin (4)
- # events (2)
- # fulcro (36)
- # graphql (7)
- # gratitude (1)
- # interceptors (13)
- # jobs-discuss (3)
- # kaocha (13)
- # membrane (3)
- # minecraft (2)
- # nbb (8)
- # off-topic (135)
- # pathom (30)
- # podcasts (1)
- # re-frame (24)
- # releases (1)
- # shadow-cljs (26)
- # sql (16)
- # squint (6)
- # tools-deps (4)
- # xtdb (8)
Is there a way to change working directory(`cd`) for the calling process? Essentially making babashka behave as cd
?
No this isn't possible, it's a JVM limitation. You can however spawn a new bb process within a new directory, if that helps.
Thank you I thought so… It wouldn’t really help I made a script that clone git repos into the file structure I like. I wanted it to also be able to jump to the new dir.
No makes sense. Thank you for the, as always, quick response!
yes, cd
is a bash built-in. There is no binary called cd
on your computer. Try which cd
and it will come back blank.
crispin@vash:~$ echo "cd /etc" > test.sh
crispin@vash:~$ chmod a+x test.sh
crispin@vash:~$ ./test.sh
crispin@vash:~$ source test.sh
crispin@vash:/etc$
your programme would have to spit out bash for you to source though... might be tricky
Thanks crispin! So I guess I would write a bash wrapper that calls my clone script that returns the path to cd
to.
some virtual language wrappers (like virtualenv in python or rbenv in ruby) spit out a script that you source to "activate" the virtual env
@U04V15CAJ I get an Exception when I try to ^D
out of the shell that command starts. Is that expected?
you can also use exec
to replace bb with the shell:
bb -e '(babashka.process/exec [(System/getenv "SHELL")] {:dir "/tmp"})'
Nice, that one shuts down nicely.
@U021UJJ3CQ6 This should work:
bb -e '(do (babashka.process/shell {:dir "/tmp"} (System/getenv "SHELL")) nil)'
@U04V15CAJ Thank you very much the both of you. It now works as I wanted! See the full script here if you want: https://gist.github.com/zoren/371baf6afbc2327832bb86ae70d5c4cd