6.9. Command ExecutionWhen you type a command to Bash or ksh93, they look in the following places until they find a match:
The distinction between "special" built-in commands and nonspecial ones comes from POSIX. This distinction, combined with the command command, makes it possible to write functions that override shell built-ins, such as cd. For example: cd ( ) { Shell function, found before built-in cd command cd "$@" Use real cd to change directory echo now in $PWD Other stuff we want to do } In ksh88, the search order is different; all built-ins are found before shell functions. Thus you have to do more work to override a built-in command with a function. You do so using a combination of functions and aliases: _cd ( ) { Shell function, note leading underscore cd "$@" Use real cd to change directory echo now in $PWD Other stuff we want to do } alias cd=_cd Alias found first |