HP-UX Reference (11i v1 05/09) - 1 User Commands N-Z (vol 2)

s
sh-bourne(1) sh-bourne(1)
commands.
The environment for any simple-command can be augmented by prefixing it with one or more assignments
to parameters. Thus:
TERM=450 cmd
and
(export TERM; TERM=450; cmd)
are equivalent (as far as the execution of cmd is concerned).
If the
-k option is set, all keyword arguments are placed in the environment, even if they occur after the
command name. The following first prints
a=b c
and then c:
echo a=b c
set -k
echo a=b c
Signals
The INTERRUPT and QUIT signals for an invoked command are ignored if the command is followed by
& and the command does not override the SIGINT and SIGQUIT signal settings it inherited from
/usr/old/bin/sh; otherwise signals have the values inherited by the shell from its parent, with the
exception of signal 11 (but see also the
trap command below).
If a SIGWINCH signal is received, sh determines the new size of the display area and resets the values of
the LINES and COLUMNS variables appropriately. Note that the value of either variable is modified only
if that variable exists at the time SIGWINCH is received. sh does not create these variables. Any traps
set on SIGWINCH are executed immediately after LINES and COLUMNS are reset.
Execution
Each time a command is executed, the above substitutions are carried out. If the command name matches
one of the Special Commands listed below, it is executed in the shell process. If the command name does
not match a Special Command, but matches the name of a defined function, the function is executed in the
shell process (note how this differs from the execution of shell procedures). The positional parameters
$1,
$2, ... . are set to the arguments of the function. If the command name matches neither a Special Com-
mand nor the name of a defined function, a new process is created and an attempt is made to execute the
command via exec(2).
The shell parameter
PATH defines the search path for the directory containing the command. Alternative
directory names are separated by a colon (:). The default path is :/usr/bin (specifying the current
directory and
/usr/bin, in that order). Note that the current directory is specified by a null path name,
which can appear immediately after the equal sign or between the colon delimiters anywhere else in the
path list. If the command name contains a / the search path is not used (such commands are not executed
by the restricted shell). Otherwise, each directory in the path is searched for an executable file. If the file
has execute permissions but is not a directory or an executable object code file, it is assumed to be a script
file which is a file of data for an interpreter. If the first two characters of the script file are
#!, exec (see
exec(2)) expects an interpreter path name to follow.
exec then attempts to execute the specified inter-
preter as a separate process to read the entire script file. If a call to
exec fails, /usr/old/bin/sh is
spawned to interpret the script file.
A parenthesized command is also executed in a sub-shell. The location in the search path where a com-
mand was found is remembered by the shell (to help avoid unnecessary
execs later). If the command was
found in a relative directory, its location must be re-determined whenever the current directory changes.
The shell forgets all remembered locations whenever the PATH variable is changed or the hash -r com-
mand is executed (see below).
Special Commands
The following commands are executed in the shell process. Input/output redirection is permitted for these
commands. File descriptor 1 is the default output location.
: No effect; the command does nothing. A zero exit code is returned.
. file Read and execute commands from file and return. The search path specified by
PATH is used to find the directory containing file. Note that this command does not
spawn another shell to execute file, and thus differs in behavior and output from exe-
cuting file as a shell script. It is not necessary that the execute permission bit be set
Section 1886 Hewlett-Packard Company 5 HP-UX 11i Version 1: September 2005