Bash script execution with and without shebang in Linux and BSD
Since this happens in dash and dash is simpler, I looked there first. Seems like exec.c is the place to look, and the relevant functionis are tryexec, which is called from shellexec which is called whenever the shell things a command needs to be executed. And (a simplified version of) the tryexec function is as … Read more