On Wed, Mar 14, 2018 at 08:43:45AM -0400, Greg Wooledge wrote: > > 1) You do not provide a hash-bang (i.e. #!/bin/bash), which means that > > /bin/sh will be used ( > > No, that's incorrect. When bash tells the operating system to run > this program, the operating system will return ENOEXEC (Exec format > error). Bash (and every other shell) will catch this and spawn a > child copy of itself to try to interpret the program as a script.
Thank you for the correction. What misled me is that the *p variants of exec() function do fallback to /bin/sh, > Special semantics for execlp() and execvp() > [...] > If the header of a file isn't recognized (the attempted execve(2) failed with > the error ENOEXEC), these functions will execute the shell (/bin/sh) with the > path of the file as its first argument. (If this attempt fails, no further > searching is done.) from: https://linux.die.net/man/3/execvp Of course, this is incorrect for bash's case, since it uses execve(), which does not exhibit this special behavior.