3 ms·
Yeah I guess I read that too quickly -- sorry. This: #!python3 Seems to work (i.e., search $PATH) on macos but AFAIK nowhere else. It fails on both ubunt
by tgamblin 6y ago
Yeah I guess I read that too quickly -- sorry.
This:
#!python3
Seems to work (i.e., search $PATH) on macos but AFAIK nowhere else. It fails on both ubuntu20 and centos8. Per this: https://www.in-ulm.de/~mascheck/various/shebang/ https://www.in-ulm.de/~mascheck/various/shebang/, relative paths are supposed to be interpreted as relative to ., so I'm guessing that is why everyone uses /usr/bin/env.
Given that shebang is implemented in the kernel (and not in user-space like coreutils) I think env is more likely to change than the shebang mechanism, though who knows -- there have been recent changes to shebang so perhaps further work on this will help: https://lwn.net/Articles/779997/ https://lwn.net/Articles/779997/.
- chrismorgan 6y agoThe shell you’re using matters, too; I find that PATH search happens when starting things from zsh, but not bash or sh. That might be why you observe it working on macOS, I dunno—they switched to zsh a while back, didn’t they? I’m not sure how much is in the kernel and how much is elsewhere, but I do observe that the shell is at least partly responsible for the error message like `bash: /path/to/script-with-shebang: python3: bad interpreter: No such file or directory`.