ksh.1 (2010 09)

k
ksh(1) ksh(1)
is typed.
A job run in the background stops if it tries to read from the terminal. Background jobs normally are
allowed to produce output, but can be disabled by giving the
stty tostop command. If the user sets
this tty option, background jobs stop when trying to produce output.
There are several ways to refer to jobs in the shell. A job can be referred to by the process ID of any pro-
cess in the job or by one of the following:
%number The job with the given number.
%string Any job whose command line begins with string .
%?string Any job whose command line contains string .
%% Current job.
%+ Equivalent to %%.
%- Previous job.
The shell learns immediately when a process changes state. It informs the user when a job is blocked and
prevented from further progress, but only just before it prints a prompt.
When the monitor mode is on, each background job that completes triggers any trap set for
CHLD.
Attempting to leave the shell while jobs are running or stopped produces the warning,
You have
stopped (running) jobs. Use the jobs command to identify them. An immediate attempt to
exit again terminates the stopped jobs; the shell does not produce a warning the second time.
Signals
The INT and QUIT signals for an invoked command are ignored if the command is followed by
& and the
monitor option is off. 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).
Execution
Substitutions are made each time a command is executed. If the command name matches one of the Spe-
cial Commands listed below, it is executed within the current shell process. Next,
ksh checks the com-
mand name to determine whether it matches one of the user-defined functions. If it does,
ksh saves the
positional parameters and then sets them to the arguments of the function call. The positional parameter
0 is set to the function name. When the function completes or issues a return,
ksh restores the posi-
tional parameter list and executes any trap set on
EXIT within the function. The value of a function is
the value of the last command executed.
A function is executed in the current shell process. If a command name is not a special command or a
user-defined function,
ksh creates a process and attempts to execute the command using
exec (see
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
/usr/bin
and the current directory in that order).
Note that the current directory is specified by a null path name which can appear immediately after the
equals sign, between colon delimiters, or at the end of the path list.
The search path is not used if the command name contains a
/. 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 interpreter as a separate process to read the entire script file. If a call to exec fails,
/usr/bin/ksh is spawned to interpret the script file. All non-exported aliases, functions, and named
parameters are removed in this case.
If the shell command file does not have read permission, or if the setuid and/or setgid bits are set on the
file, the shell executes an agent to set up the permissions and execute the shell with the shell command
file passed down as an open file. A parenthesized command is also executed in a sub-shell without remov-
ing non-exported quantities.
Command Re-entry
The text of the last HISTSIZE (default 128) commands entered from a terminal device is saved in a his-
tory file. The file $HOME/.sh_history is used if the HISTFILE variable is not set or writable. A
shell can access the commands of all interactive shells that use the same named HISTFILE.
HP-UX 11i Version 3: September 2010 11 Hewlett-Packard Company 11