int execve(const char *pathname, char *const argv[], char *const envp[]);
pathname
: The path of file that is going to be executed.argv[]
: an array of pointers to strings passed to the new program as its command-line arguments.
argv[0]
being the program name is a custom.envp[]
: an array of pointers to strings, conventionally of the form key=value
.form of shebang
#!interpreter [optional-arg]
NOTE: There can be only one [optional-arg]
: How programs get run
After checking those first two bytes, this code parses the rest of the script-invocation line, splitting it into an interpreter name (everything after #! up to the first white space) and possible arguments (everything else up to the end of the line, stripping external white space).
[source code] how does kernel handle script file
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/binfmt_script.c
How programs get run
The case of the supersized shebang
The #! magic, details about the shebang/hash-bang mechanism on various Unix flavours
man page execve(2)