Open System Services Shell and Utilities Reference Manual (G06.27+, H06.04+)
ksh(1) OSS Shell and Utilities Reference Manual
command runs as a separate process, and the shell waits for the last command to end. A filter is a
command that reads its standard input, transforms it in some way, then writes it to its standard
output. A pipeline normally consists of a series of filters. Although the processes in a pipeline
(except the first process) can execute in parallel, they are synchronized to the extent that each
program needs to read the output of its predecessor.
The exit value of a pipeline is the exit value of the last command.
A list is a sequence of one or more pipelines separated by ; (semicolon), & (ampersand), &&
(two ampersands), or || (two vertical bars) and optionally ended by a ; (semicolon), an & (amper-
sand), a |& (coprocess), or a newline. These separators and terminators have the following
effects:
; Causes sequential execution of the preceding pipeline; the shell waits for the pipeline
to finish.
& Causes asynchronous execution of the preceding pipeline; the shell does not wait for
the pipeline to finish.
&& Causes the list following it to be executed only if the preceding pipeline returns a 0
(zero) exit value.
|| Causes the list following it to be executed only if the preceding pipeline returns a
nonzero exit value.
The cd command is an exception; if it returns a nonzero exit value, no subsequent com-
mands in a list are executed, regardless of the separator characters.
The ; and & separators have equal precedence, as do && and ||. The single-character separators
have lower precedence than the double-character separators. An unquoted newline character fol-
lowing a pipeline functions the same as a ; (semicolon).
Comments
The shell treats as a comment any word that begins with a # character and ignores that word and
all characters following up to the next newline character.
Shell Flow Control Statements
Unless otherwise stated, the value returned by a command is that of the last simple command
executed in the command.
for identifier [in word...] ;do list ;done
Each time a for command is executed, identifier is set to the next word taken from the
in word list. If in word ... is omitted, the for command executes the do list once for
each positional parameter that is set. (See Parameter Substitution.) Execution ends
when there are no more words in the list.
select identifier [in word...] ;do list ;done
Prints on standard error (file descriptor 2) the set of words, each word preceded by a
number. If in word... is omitted, then the positional parameters are used instead. (See
Parameter Substitution.) The PS3 prompt is printed and a line is read from the stan-
dard input. If this line consists of the number of one of the listed words, then the value
of the parameter identifier is set to the word corresponding to this number. If this line
is empty, the selection list is printed again. If neither of these cases is true, the value of
the parameter identifier is set to null. The contents of the line read from standard input
is saved in the REPLY parameter. The list is executed for each selection until a break
or end-of-file character is encountered.
5−8 Hewlett-Packard Company 527188-004