Fork me on GitHub

Hey, there was a way to write a bb script but have the first part be Bash right? e.g. the bash part would download bb in case it's not there


I think just writing a bash script which then invokes another bb script is easier though


Yeah that probably is


Thanks, I'll look into this


New video: How to use a library from clojars in a babashka script: I use @seancorfield's honeysql v2 as an example.

👏 24
Eamonn Sullivan15:02:33

@borkdude, I made a very simple (probably throw-away) PR on babashka/fs. I'm working my way slowly to the equivalent of cp -al (copy tree, with attributes, but using hard links). I also just wanted to see if I can create a PR. Feel free to ignore.

thumbsup_all 3
Eamonn Sullivan15:02:35

Probably the way to do that is to modify ->copy-opts, maybe?

Eamonn Sullivan16:02:37

Nah, it's not one of the standard options. I guess I'd need to use walk-file-tree.


Looks good to me, the PR.


@UR71VR71S Is there anything you are missing in copy-tree?


Copying a tree using hard links: I'm not sure if this is something that is used a lot?

Eamonn Sullivan16:02:09

In some back up systems, like Apple's TimeMachine (I think that's what it is called), they use hard-links to snapshot the contents of a directory as it appeared at a certain period of time in the past. Hard links are useful in that circumstance because they take up almost no extra space. It's just another name for a single inode. If the user deletes the file, the file will still exist (under a different name) if they want to recover it. My very simple babashka does that.


yeah, you could do that using walk-file-tree and copy-link (which I will merge now, if you have no objections?)

Eamonn Sullivan16:02:09

Sounds good to me. Thank you!


Should we also add a predicate for this?


Hmm, it seems the Files class doesn't have such a thing either. Maybe that doesn't apply to hard links

Eamonn Sullivan16:02:41

I hadn't thought of that. As far as the file system is concerned, they are the exact same file, just with a different name. Like an alias, I guess. But ls knows that a file has more than one name (there is a little number that increments when you do an ls -l). So there must be some attribute that would could check.


yeah, I think we're good for now

Eamonn Sullivan16:02:40

There is a method for this in java (.isSameFile path1 path2), but my Java interop chops are poor and I can't seem to get it to work.


@UR71VR71S This is already in fs as same-file?

Eamonn Sullivan16:02:57

As yes, so it is, and it works as a predicate. Do you want me to add that to the test?

(is (fs/same-file? (fs/file tmp-dir "dudette.txt")
                   (fs/file tmp-dir "hard-link.txt")))
Something like that?


yeah, would be good to add I think

Eamonn Sullivan16:02:47

OK, will make a separate very little PR. One sec.


It's not so clear to me if same-file? will return false for a soft link, from those docs


But it probably will

Eamonn Sullivan16:02:23

I tried to find a create-sym-link test, but I don't see it. Just to prove that same-file? would return false here.


create-sym-link is used in a bunch of places in the tests, but there is not a dedicated test for it. feel free to add it

Eamonn Sullivan17:02:46

Well, just for your info: same-file? returns true for both sym links and hard links, so not a predicate in itself for this particular thing. But :man-shrugging: adding it to the test doesn't hurt and makes it clearer, anyway. You've made me curious now. Going to poke around this a little bit. The Posix stat() API would work, if that's possible in Java.

Eamonn Sullivan18:02:02

I've updated the pull request for the expanded test, btw.


Thanks, merged


TIL. On Youtube.

🎉 27

thank you for including hiccup in babashka ❤️ so nice.

👍 12
❤️ 6