174 points · by kingori · 8y ago · 32 comments
Can you imagine a future where you don't have to install runtimes to run things anymore because they are all distributed with everything you need? It would be amazing and magical in many ways. No more reinstalling the OS because things got weird after X went berserk.
Being forced to pollute my perfect, pristine machines with multiple versions of Python, or having to even commit to a single version of anything seems less good than not having to.
I'd rather burn the extra HDD space to avoid risky installs messing up the system.
Of course three copies of the binary is not ideal, but it shouldn't even be necessary. With some deep hacking the platform-specific code could be minimized and the rest of the binary could be shared. Wouldn't it be fun to have truly platform-independent binary executables?
[1] https://gist.github.com/jdarpinian/6860ddfd92b5b458a20ab6055...
What about packaging - e.g. this file having a proper icon on Windows? What about distribution via the app market platforms?
How do I go about upgrading the application?
i.e.
assoc
assoc .vbs=txtfile
assoc .mp4=WMP11.AssocFile.MP4
Perhaps it may be worth considering security practices for BINFMT_MISC before people find any sub-optimal defaults. In the past, clever people would exploit some of the default associations that applications would insert on Windows desktops. At some point, desktop file exploring apps may decide to hide "known extensions. The desktop will also leverage this association.I also believe that xdg-open (and the XDG scheme) is more similar to Windows' file associations than binfmt_misc, since XDG is more of a user-facing thing.
///bin/true; exec /usr/bin/env go run "$0" "$@"
See https://stackoverflow.com/a/30082862/334761 for detailed explanation what's going on there. The only downside is that all exit codes != 0 get mapped to exit code 1 by `go run`. It will show the original exit code on stderr instead.Compared to that, the example snipped you provided is doing many more, and different things:
1. Launches a shell language interpreter: usually the system default POSIX-compliant sh, but could (rarely) be something else. Compared to "read the first line, and if it's a shebang launch python or whatever" in the kernel, this is massively complicated: it starts another whole runtime. Run "strace" on a file that just does "///bin/true; sleep 1000" to see exactly how much is happening just for that shell launch.
1. Executes /bin/true. It's probably present everywhere, and probably the right program, but still an assumption.
2. Evaluates a bunch of string slinging statements in the shell to interpolate arguments, then replaces itself via "exec".
3. Launches /usr/bin/env (hopefully the right program, and hopefully in the right place) to find the go interpreter.
4. env (hopefully) also calls "exec" again and then launches the go run command to start the compilation/execution sequence.
That's a lot of stuff. Pretty garden-variety stuff, but still a lot of additional complexity. A shebang adds none of it, though "trampolining" shebangs (which themselves are just programs to do basically this) can reintroduce some internally.
That's the beauty of the shebang as a trick for truly interpreted languages: it's extremely direct and simple as a means of getting your code executing on your desired runtime.
...
>Imagine if an entire OS had all the languages packaged this way so that everything could be “dot slashed” and executed but without actually installing the language to your host operating system.
This has been technically possible for decades, but the disadvantages (startup time, memory use, disk use) outweigh the advantages. (better security, assuming no VM escape bugs, which is an assumption you absolutely can't make, considering the long list of Xen CVEs) Breezily asserting the superiority of this solution without acknowledging any possible downsides is also strange... more press release than blog post.
Also, this is a write-up about something cool that author discovered. It’s about the fact that dot slash isn’t magic, but rather a feature which can be (ab)used to do something out of the ordinary. Sounds like a blog post to me.
https://nvd.nist.gov/vuln/search/results?adv_search=false&fo...
https://nvd.nist.gov/vuln/search/results?adv_search=false&fo...
Suppose that would admit not knowing something... certainly not something we should be encouraging!