Fork me on GitHub
#babashka
<
2022-01-02
>
huygn09:01:41

happy new year! is it absolutely impossible to run cd during a bb script? my goal involving cloning a git repo & cd to cloned dir

borkdude09:01:50

@gnhuy91 why would you like to cd? can you elaborate on what comes after that?

huygn09:01:06

no more after cd, I wanted to have a quick script to clone a repo & cd to it right away

borkdude09:01:23

and then drop back into bash?

borkdude09:01:50

this isn't even possible with bash unless you use source right?

borkdude09:01:39

Hmm, that doesn't work for me.

#!/usr/bin/env bash

cd /tmp
[email protected] ~/Dropbox/dev/clojure/http-server (main) $ /tmp/foo
[email protected] ~/Dropbox/dev/clojure/http-server (main) $

borkdude09:01:28

But to answer your question, the bb way to do this would be to start a new shell using (shell {:dir "the-dir"} (System/getenv "SHELL"))

borkdude09:01:53

This will start your default shell in the the-dir directory

borkdude09:01:30

shell is from babashka.tasks

huygn09:01:19

oh yea had to source that file prior to the command, yea

huygn10:01:52

cool, that works for my usecase 👌

huygn10:01:26

dumb question - how can I print command output (as they come) with babashka.process?

borkdude10:01:42

:inherit true

borkdude10:01:02

or use babashka.tasks/shell

huygn10:01:20

ah, that's a convenient one

Dimitar Uzunov20:01:27

wait is this like tee?

Dimitar Uzunov20:01:43

oh wow will test this out, I got a case where I’m running something in CI and the job is silent for up to 10 minutes, I would rather have output in that time 😄

borkdude20:01:36

It's not like tee, but the output is just displayed in real time, not captured into a string

borkdude20:01:12

Although you could use tee to both print and capture the output ;)

huygn00:01:13

yea its like streaming the output from that process to the main process you're running bb

huygn00:01:42

had it working https://github.com/huygn/gh/blob/master/src/gh/main.clj thanks! now making it globally runnable in my machine, currently using uberscript & a small bash function to source it

Benjamin09:01:26

can I download the executable for windows somewhere? (don't have windows so don't have scoop)

borkdude09:01:16

Yes, on Github releases

👀 1
Benjamin09:01:51

ah yea thanks

pez12:01:21

Can I combine -f and -m options to bb? I get some super weird behaviour in trying this.

borkdude12:01:00

What's the use case? -f and -m are mutually exclusive but bb does support --init

borkdude12:01:23

bb --init foo.clj -m foo/bar

pez12:01:49

I just misunderstood the docs. I'll try with init.

pez12:01:08

Yes, --init did the trick. Seems you could read my mind about my use case. 😃

borkdude12:01:36

Still curious

pez16:01:16

It’s for my primes sieving. I need to create a docker file that can run the various babashka implementations of the sieve.

borkdude16:01:24

right. I think --init usage is pretty rare, so when people do use it, I'm interested as to why

pez17:01:30

In my case it is mostly that I have a run script using -X for the Clojure sieves, and translating that to babashka was how I ended up here. 😃

borkdude17:01:54

How does -X translate into --init + m?