Fork me on GitHub
#babashka
<
2021-05-19
>
grazfather15:05:06

that whole repo is nice

Max17:05:16

Is there a way to get the name the script was executed with? It’s usually the first argument, but it appears babashka strips it off. For example:

bb -e true => bb
./my-script.bb 1 2 3 => ./my-script.bb 

borkdude17:05:23

@max.r.rothman the file being executed is available in (System/getProperty "babashka.file")

Max17:05:18

That gets the file, but it doesn’t tell you how the script was executed. For example, if the script has a shebang and is in your path, it still shows the full path to the file

borkdude17:05:59

it has the absolute path yes, like *file*

borkdude17:05:03

This is by design, so you can do: (= *file* (System/getProperty "babashka.file")) to know if the current file is what the user invoked

borkdude18:05:06

If your question is: how do I get a filename from an absolute path, you can use babashka.fs/file-name