5 ms·
> even putting #!/bin/python3 at the head of a script so that it runs through the shell. It's not the shell, it's the kernel that interprets the so-called sheb
by smcameron 3y ago
> even putting #!/bin/python3 at the head of a script so that it runs through the shell.
It's not the shell, it's the kernel that interprets the so-called shebang.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/binfmt_script.c#n34 https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/lin...
Edit: oops, should have previewed, cryptonector beat me to it.
- soraminazuki 3y agoYep, imagine how things would be like if the kernel didn't understand shebangs. exec() calls would fail for non-ELF executables and we'd be devising all sorts of ridiculous workarounds. We're lucky that didn't happen.
- cesarb 3y ago> Yep, imagine how things would be like if the kernel didn't understand shebangs. exec() calls would fail for non-ELF executables and we'd be devising all sorts of ridiculous workarounds. We're lucky that didn't happen. Actually, that did happen. Quoting https://utcc.utoronto.ca/~cks/space/blog/unix/ExecAndShebangHistory https://utcc.utoronto.ca/~cks/space/blog/unix/ExecAndShebang... "In V7 (and versions before it), the exec*() family of system calls only worked on actual binary executables. In order to make shell scripts more or less work, the shell (and I think perhaps some other programs) reacted to an ENOEXEC error by assuming the executable was actually a shell script." And yes, the ridiculous workaround (treating the file as a shell script when it's not an executable) seems to still exist to this day.