MPE/iX Shell and Utilities Reference Manual, Vol 2
sh(1) MPE/iX Shell and Utilities sh(1)
2. sh performs word expansion on variable assignments. If there is no command or the
command is a special built-in command (see Built-in Commands), variable assign-
ments affect the current environment; otherwise, variable assignments affect the exe-
cution environment of the command.
3. sh does redirection, performing word expansion on any file names (see File Descrip-
tors and Redirection).
sh next searches for the command name and executes the command. If the command name is
a special built-in command, sh invokes it. Most errors in special built-ins cause a non-
interactive shell to exit.
If the command name is a function, sh executes the function. You can disable the search for
functions with the built-in command named command
If the command name is a regular built-in command, sh invokes it.
If the command name is not a regular or special built-in command or a function, sh searches
for an executable file containing a shell script or a program. The shell uses one of the follow-
ing two methods to locate this file.
• If the command name typed to the shell has slash (/) characters in its name, the command
is taken to be a full path name (absolute or relative). The shell tries to execute the con-
tents of that file.
• Otherwise, the shell performs a path search. To do this, the shell obtains the value of the
PATH
variable. The value should be a list of directory names. sh searches under each
directory for a file names that matches the command name and executes the first matching
file found.
If the path search fails, the command exit status is 127. If sh cannot execute the program and
it is not a shell script, the exit status is 126.
Command names may be marked as tracked aliases. The first time you execute a command
with a tracked alias, the shell does a normal
PATH
search. If the search is successful, the shell
remembers the file it finds. The next time you execute a command with the same name, sh
immediately executes the file found on the last
PATH
search; there is no new search. This
speeds up the search for the appropriate file.
The set –h command tells the shell that all commands should be treated as tracked aliases.
See alias(1) and set(1) for more information.
1-526 Commands and Utilities