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

s
sh-posix(1) sh-posix(1)
is the exit status of the last command in the pipeline. Otherwise, the exit status of the pipeline is the logi-
cal negation of the exit status of the last command in the pipeline.
A list is a sequence of one or more pipelines separated by
;, &, &&,or||, and optionally terminated by
;,
&,or|&.
; Causes sequential execution of the preceding pipeline. An arbitrary number of newlines can
appear in a list, instead of semicolons, to delimit commands.
& Causes asynchronous execution of the preceding pipeline (that is, the shell does not wait for that
pipeline to finish).
|& Causes asynchronous execution of the preceding command or pipeline with a two-way pipe esta-
blished to the parent shell. The standard input and output of the spawned command can be
written to and read from by the parent shell using the
-p option of the special commands read
and print.
&& Causes the list following it to be executed only if the preceding pipeline returns a zero value.
|| Causes the list following it to be executed only if the preceding pipeline returns a nonzero value.
Of these five symbols, ;, &, and |& have equal precedence, which is lower than that of
&& and ||. The
symbols
&& and || also have equal precedence.
Compound Commands
Unless otherwise stated, the value returned by a compound command is that of the last simple command
executed in the compound command. The ; segment separator can be replaced by one or more newlines.
The following keywords are recognized only as the first word of a command and when not quoted:
! } elif for then
[[ case else function time
]] do esac if until
{ done fi select while
A compound command is one of the following.
case word in [[;][(] pattern [| pattern]...)
list ;;]... ; esac
Execute the list associated with the first pattern that matches word. The form of the patterns is
identical to that used for file name generation (see the "File Name Generation" subsection). The
;;
case terminator cannot be replaced by newlines.
for identifier [in word ... ] ; do list ; done
Set identifier to each word in sequence and execute the do list.Ifin
word ... is omitted, set
identifier to each set positional parameter instead. See the "Parameter Substitution" subsection. Exe-
cution ends when there are no more positional parameters or words in the list.
function identifier { list ;}
identifier () { list ;}
Define a function named by identifier. A function is called by executing its identifier as a command.
The body of the function is the list of commands between { and }. See the "Functions" subsection.
if list ; then list ; [elif list ; then list ;]... [else list ;] fi
Execute the if list and, if its exit status is zero, execute the first then list. Otherwise, execute the
elif list (if any) and, if its exit status is zero, execute the next then list. Failing that, execute the
else list (if any). If no else list or then list is executed, if returns a zero exit status.
select identifier [in word ...] ;dolist ; done
Print the set of words on standard error (file descriptor 2), each preceded by a number. If in word ...
is omitted, print the positional parameters instead (see the "Parameter Substitution" subsection).
Print the PS3 prompt and read a line from standard input into the parameter REPLY. If this line
consists of the number of one of the listed words, set identifier to the corresponding word,execute
list, and repeat the
PS3 prompt. If the line is empty, print the selection list again, and repeat the
PS3 prompt. Otherwise, set identifier to null, execute list, and repeat the PS3 prompt. The select
loop repeats until a break special command or end-of-file is encountered.
Section 1894 Hewlett-Packard Company 3 HP-UX 11i Version 1: September 2005