Hacker News new | ask | show | jobs
by obverse 2050 days ago
I've tried going down that rabbit hole before. The primary issue that stopped me was the different executable file formats.

I never took it anywhere, but I think the way to go would be a "polyglot" script that could be interpreted by different script engines (sh/bat) that would then pick the correct executable for the given OS. This would require the user to change the file extension as well as download multiple executable files so I don't necessarily like this solution from an elegance stand point.

1 comments

I've had good success with shebangs combined with zip archives containing python code. Zip files use a footer rather than a header, and python natively supports executing scripts out of them. The beginning of the file can have a shebang, allowing it to specify the interpreter to use. The only trick is that windows doesn't support shebangs, and so you need to associate your chosen file extension with python on every system. Also, you need python installed obviously.

What that gives you is a stable entry point into python code. From there, you can run whatever platform specific code you want.