From bash manual:
3.7.2 Command Search and Execution
After a command has been split into words, if it results in a simple command and an optional list of arguments, the following actions are taken.
If the name is neither a shell function nor a builtin, and contains no slashes, Bash searches each element of $PATH for a directory containing an executable file by that name.
If the search is successful, or if the command name contains one or more slashes, the shell executes the named program in a separate execution environment. Argument 0 is set to the name given, and the remaining arguments to the command are set to the arguments supplied, if any.
If this execution fails because the file is not in executable format, and the file is not a directory, it is assumed to be a shell script and the shell executes it as described in Section 3.8 [Shell Scripts], page 39.
Suppose a bash script
myscriptdoesn't contain a shebang.
Does the quote mean that if the script is executed in bash via command
bash will first assume it is an ELF and calls
execve()on it, and because it is a bash script not ELF,
execve()call will fail,
bash will next execute
Compared to running a bash script via
bash myscriptin bash, running the script via
myscriptin bash will additionally have a failure call to
execve()on the script directly?
If yes, is
bash myscript? Why does "A Practical Guide to Linux Commands, Editors, and Shell Programming By Mark G. Sobell" say the opposite?
Although you can use bash to execute a shell script, this technique causes the script to run more slowly than giving yourself execute permission and directly invoking the script.
If a bash script
myscriptcontains a shebang
#! /bin/bash, when it is executed in bash via command
is it executed in the same way as it is executed in bash via command
is it executed in the same way as the shebang were removed from the script and then the script were executed via command