Fork me on GitHub
#babashka
<
2024-07-09
>
Jonathan D Johnston01:07:31

This might be too off-topic for the Babashka Book, but I have a simple alternative to your clever "beside" .bat for Windows. I can run any http://script.bb in PATH by simply typing script. To do so, I FTYPEd .bb as something like (name doesn't matter) bbscript, ASSOCed bbscript with the abspath to bb.exe, and added .BB to the PATHEXT environment variable. Not as clean as #!, but it works. CAVEAT: I've never tried this on anything newer than Windows 7

Jonathan D Johnston01:07:51

Oops, I got ASSOC & FTYPE backwards. Sorry. Also, I probably needed Administrator privileges to make it persistent. If that's not a showstopper, it's a handy option, especially for polyglot programmers

borkdude07:07:48

Perhaps you can make a full standalone example of what you are saying, e.g. as a gist or so? Please use threads when posting messages about the same topic. Thanks

Jonathan D Johnston17:07:21

@U04V15CAJ I hope https://gist.github.com/jdjohnston/3965acd9424cf2028181a6d6389141f6 explains better what I was trying to suggest. Sorry about the non-threading.

borkdude18:07:22

@UH7SJ6UKG This is very cool, thanks for sharing!

Jonathan D Johnston18:07:54

@U04V15CAJ Glad you found it of interest! :)

Adham Omran07:07:46

I have an issue when using shell to run a cp command Minimal example

{:tasks
 {copy (shell "cp -r ./dir/* .")}}
This is my ls -la
drwxr-xr-x 5 adham users  4096 Jul  9 10:11 .
drwxr-xr-x 6 adham users  4096 Jun 24 11:36 ..
-rw-r--r-- 1 adham users   585 Jul  9 10:10 bb.edn
drwxr-xr-x 2 adham users  4096 Jul  9 10:11 dir
-rw-r--r-- 1 adham users    10 Jun 13 10:26 .envrc
-rw-r--r-- 1 adham users   564 Jun 13 10:26 flake.lock
-rw-r--r-- 1 adham users  1066 Jun 13 10:26 flake.nix
drwxr-xr-x 8 adham users  4096 Jul  9 10:10 .git
-rw-r--r-- 1 adham users   319 Jul  9 10:07 .gitignore
-rw-r--r-- 1 adham users 35149 Jul  9 09:27 LICENSE
-rw-r--r-- 1 adham users  1587 Jul  9 09:46 README.md
The error I get is
cp: cannot stat './dir/*': No such file or directory
Error while executing task: copy
Running cp -r ./dir/* . works as intended.

borkdude07:07:29

shell shells out to programs, it isn't running a bash command

borkdude07:07:07

if you want to run bash, you should call bash like:

(shell "bash" "-c" "cp -r ...")

borkdude07:07:14

You can also use babashka.fs to copy files

Adham Omran07:07:23

I see, thank you!

Adham Omran07:07:12

Thanks to babashka this

Tomas Brejla09:07:26

@U03QTHYKXK7 perhaps you even no longer need that leading paragraph to contain link to deps-new after the cleanup? (unless it's important and the people using that training should be aware of deps-new being used internally by the setup task)

Adham Omran08:07:22

Hey @U01LFP3LA6P, thank you for the note https://github.com/idata-iq/backend-template is meant to on-board people new to Clojure for a training so I put the note in case they come across Leiningen at some point later to understand how we made the projects

👍 1