| Here's another POSIXism that everybody gets wrong: command lookup for sh; follow this algorithm for executing a command with no slashes, consider what would happen if "echo" is not in your path. Try it out on any shell and see that it just runs the "echo" builtin despite it being required to return 127. Text below taken from: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3... If the command name matches the name of a special built-in utility, that special built-in utility shall be invoked. If the command name matches the name of a function known to this shell, the function shall be invoked as described in Function Definition Command. If the implementation has provided a standard utility in the form of a function, it shall not be recognized at this point. It shall be invoked in conjunction with the path search in step 1d. If the command name matches the name of a utility listed in the following table, that utility shall be invoked. alias
bg
cd
command false
fc
fg
getopts jobs
kill
newgrp
pwd read
true
umask
unalias wait Otherwise, the command shall be searched for using the PATH environment variable as described in XBD Environment Variables : If the search is successful: <snip> If the search is unsuccessful, the command shall fail with an exit status of 127 and the shell shall write an error message. |
"If the command name matches the name of a special built-in utility, that special built-in utility shall be invoked."
Let echo be a "special built-in utility", and sh is compliant.