babashka.fs
has file-name
but no dir-name
or am I missing something?
$ bb '(fs/file-name (fs/real-path "."))'
"babashka"
file-name
just means the name part of a pathThe docstring also says that: Returns the name of the file or directory.
Yeah, so it is like basename
, right?
This naming is also used by the java.nio.file package itself: https://docs.oracle.com/javase/7/docs/api/java/nio/file/Path.html#getFileName() The functions in babashka.fs are usually named after those
I have seen different implementations of basename
. Sometimes they do what fs/file-name
do, but sometimes they also strip the extension. I follow java.nio.file as much as possible in babashka.fs.
Iβm looking for the equivalent to dirname
. Given a full path it returns the directory part of it:
$ dirname /Users/peter/Projects/my-proj/README.md
/Users/peter/Projects/my-proj
(Given a path to a directory it returns the parent directory. So seems like it uses the same semantics as babashka.fs/file-name
)
$ bb '(fs/parent (fs/real-path "."))'
#object[sun.nio.fs.UnixPath 0x27773e47 "/Users/borkdude/dre/DocSearch"]
@borkdude Thanks for getting all the things for https://github.com/babashka/babashka/issues/784 in so fast! I was about to add the aset-byte and related functions by myself but you were too quick. I was writing a few tests for them at the same time so could always submit that. But I guess testing stuff defined via copy-core-var
is fairly low value right? There are assumedly tests on the core functions which cover the logic
@slack1003 True. Unless you expect GraalVM to behavior potentially weird with these functions
Dunno the GraalVM limitations well at all. All its doing is calling setByte
(etc) on Array
which surely graal can handle alright.
@slack1003 In #babashka-circleci-builds you can test the newest build from master
@borkdude iβll give it a quick run. so 76e2a241e767de2f38ac64c6f8a7e58be92fdd71 includes the latest sci changes then? Guess it gets triggered when sci updates?
@slack1003 it's triggered when I commit to babashka and I have committed the latest sci changes
@borkdude yup works for me! only tested aset-byte
on macos but all the others all go on the same principle
fs/parent
seems to be what I was looking for.
bb '(str (fs/parent "/Users/peter/Projects/my-proj/README.md"))'
"/Users/peter/Projects/my-proj"
hmm some funky behavior around combining print
and System/exit
.
This program produces no output on my machine:
#!/usr/bin/env bb
(print "hello world")
(System/exit 0)
But will if println is used instead
I have a case where I am just calling bb on a subprocess script and dumping output, err, and then exiting with the returned exit code
and noted I was not getting output if I was using print
though works fine if I call (flush)
I literally never use print so not sure if this is normal behavior or bb specific
@slack1003 This is expected behavior, it behaves the same in Clojure
k nice. never really use it so donβt remember the behavior. I added a flush to my stuff
babashka 0.3.5 https://github.com/babashka/babashka/blob/master/CHANGELOG.md
how much would including of DONEjava.security.SecureRandom
add to a size of the babashka binary?
@ales.najmann I just added that in 0.3.5 :)
π cool
so hopefully, I'll have, in few days, an example of the partial homomorphic encryption scheme written for babashka
but bear with me, I'm terrible coder.
babashka doesn't care about your coding skills
looking forward to it :)
bb 0.3.5 somewhat simplified my work bb.edn, by allowing to invoke tasks in parallel using #{p1 p2}
, thanks @maxp
https://gist.github.com/borkdude/35bc0a20bd4c112dec2c5645f67250e3#file-bb-edn-L17
To be more precise, @borkdude added support for ByteBuffer
and all the typical classes that implement it. Hence this is more significant than just BinF. Just one example, @ericihli has recently announced a trie implementation that uses ByteBuffer
. Well now who knows, maybe that kind of code can run in BB without any adaptation.
Do you have a link to it?
ok, that probably doesn't run as bb doesn't have deftype
It was worth a shot π But point is, it probably opened the door for a new set of existing libs
yep, that's always nice :)