POSIX Standard, section 3.9.1.1, line 779-784.
When the search for command name using the PATH environment variable succeeds, the command is executed with actions equivalent to calling 'execve()' with the path argument set to the pathname resulting from the search, 'argv[0]' set to the command name and the remaining arguments set to the operands.
if [ $0 = (basename $0) ]; then echo "command name: " $0 fi |
GNU Exception:
When the search for command name using the PATH environment variable succeeds, the command is executed with actions equivalent to calling 'execve()' with the path argument set to the pathname resulting from the search, 'argv[0]' set to the full-path command name and the remaining arguments set to the operands.
if [ $0 = (realpath $0) ]; then echo "full pathname: " $0 fi |
When PATH is used to locate a file for the dot utility, and a matching file is on the PATH but is not readable, the behavior is undefined (unlike POSIX which apparently requires the shell to continue searching through the rest of the PATH, POSIX Standard, section 3.14.4, line 1493-1498).