3 ms·
It should be possible to run bash scripts on any system supported by jart's cosmopolitan library [1], which provides a platform-agnostic bash executable [2]. [
by shrx 2y ago
It should be possible to run bash scripts on any system supported by jart's cosmopolitan library [1], which provides a platform-agnostic bash executable [2].
[1] https://justine.lol/cosmo3/ https://justine.lol/cosmo3/
[2] https://cosmo.zip/pub/cosmos/bin/ https://cosmo.zip/pub/cosmos/bin/
- shakna 2y agoYes and no. It does work - but there are some OS-specific stuff that can still pop up and explode on you. There are different guarantees around open/write on Windows and *nix, and cosmopolitan doesn't 100% paper over those gaping differences. It doesn't change the underlying file locking behaviour of the file system, for example. You can run into thread-time guarantees and other streaming problems, when piping from one thing to another.
- shrx 2y agoInteresting, thanks for pointing this out. Can I read more about potential pitfalls somewhere, or is it mostly trial and error?
- shakna 2y agoJustine's pretty easy to talk to and fairly available. I tend to try something, and then hit them up if things start falling apart.
- jart 2y agoWhat are these gaping differences? File locks are a horror show. No doubt. But I can't think of any truly terrible differences with the other things you mentioned.
- shakna 2y agoFile locks are the thing that has most been biting me, to be honest. The horrow show of NTFS, and Windows Defender, where a 'close' can become a costly operation.
- jart 2y agoWe could potentially create a background worker thread for closing handles.
- shakna 2y agoFrom memory, rustup ended up creating a worker for closing handles, to avoid dealing with Windows Defender. So it can be a valid approach. Though, cosmo might then run into Windows not being happy with two things attempting to open the same file, if the programmer then attempts to reopen the file. You could do some logic that cancels closing in the thread, and re-hands the handle to the user if the handle still exists, but that might be a little fragile. To be honest... There may not actually be a good answer that works 100% of the time. Working around the platform might introduce race conditions you absolutely don't want.