'\"macro stdmacro
.if n .pH g1.ksh @(#)ksh	41.2
.\" Copyright 1989 AT&T
.nr X
.if \nX=0 .ds x} ksh 1 "User Environment Utilities" "\&"
.if \nX=1 .ds x} ksh 1 "User Environment Utilities"
.if \nX=2 .ds x} ksh 1 "" "\&"
.if \nX=3 .ds x} ksh "" "" "\&"
.TH \*(x}
.\"
.\" David Korn
.\" AT&T Bell Laboratories
.\" 582-7975
.\" @(#)sh.1 (ulysses!dgk) 11/16/88
.\"
.ds OK [\|
.ds CK \|]
.\"ds ' \s+4\v@.3m@\'\v@-.3m@\s-4
.\"ds ` \s+4\v@.3m@\`\v@-.3m@\s-4
.ds ' '
.ds ` `
.SH NAME
\f4ksh\f1, \f4rksh\f1 \- KornShell, a standard/restricted command and programming language
.SH SYNOPSIS
\f4ksh\f1
[
\f4\(+-aefhikmnprstuvx\f1
] [
\f4\(+-o\f1
.I option
] .\|.\|. [
\f4\-c\f1
.I string
] [
.I arg
\&.\|.\|. ]
.br
\f4rksh\f1
[
\f4\(+-aefhikmnprstuvx\f1
] [
\f4\(+-o\f1
.I option
] .\|.\|. [
\f4\-c\f1
.I string
] [
.I arg
\&.\|.\|. ]
.SH DESCRIPTION
.I Ksh\^
is a command and programming language
that executes commands read from a terminal
or a file.
.I Rksh\^
is a restricted version of the 
command interpreter
.IR ksh ;
it is used to set up login names and execution environments whose
capabilities are more controlled than those of the standard shell.
See
.I Invocation\^
below
for the meaning of arguments to the shell.
.SS Definitions.
A
.I metacharacter\^
is one of the following characters:
.RS
.PP
\f4;   &   (   )   \(bv   <   >   new-line   space   tab\fP
.RE
.PP
A
.I blank\^
is a
\f4tab\f1
or a
\f4space\f1.
An
.I identifier\^
is a sequence of letters, digits, or underscores
starting with a letter or underscore.
Identifiers are used as names for
.I functions\^
and
.IR "variables" .
A
.I word\^
is a sequence of
.I characters\^
separated by one or more non-quoted
.IR metacharacters .
.PP
A 
.IR command\^
is a sequence of characters in the syntax
of the shell language.
The shell reads each command and
carries out the desired action either directly or by invoking
separate utilities.
A special command is a command that is carried out by the
shell without creating a separate process.
Except for documented
side effects, most special commands can be implemented as separate
utilities.
.SS Commands.
A
.I simple-command\^
is a sequence of
.I blank\^
separated words
which may be preceded by a variable assignment list
(see
.I Environment\^
below).
The first word specifies the name of the command to
be executed.
Except as specified below,
the remaining words are passed as arguments
to the invoked command.
The command name is passed as argument 0
[see
\f4exec\fP(2)].
The
.I value\^
of a simple-command is its exit status
if it terminates normally, or (octal) 200+\f2status\^\fP if
it terminates abnormally [see
\f4signal\fP(2)
for a list of
status values].
.PP
A
.I pipeline\^
is a sequence of one or more
.I commands\^
separated by
\f4\(bv\f1.
The standard output of each command but the last
is connected by a
\f4pipe\fP(2)
to the standard input of the next command.
Each command is run as a separate process;
the shell waits for the last command to terminate.
The exit status of a pipeline is the exit
status of the last command.
.PP
A
.I list\^
is a sequence of one or more
pipelines
separated by
\f4;\f1,
\f4&\f1,
\f4&&\f1,
or
\f4\(bv\|\(bv\f1,
and optionally terminated by
\f4;\f1,
\f4&\f1,
or
\f4\(bv&\f1.
Of these five symbols,
\f4;\f1,
\f4&\f1,
and
\f4\(bv&\f1
have equal precedence,
which is lower than that of
\f4&&\f1
and
\f4\(bv\|\(bv\f1.
The symbols
\f4&&\f1
and
\f4\(bv\|\(bv\f1
also have equal precedence.
A semicolon
\f1(\f4;\f1)
causes sequential execution of the preceding pipeline; an ampersand
\f1(\f4&\f1)
causes asynchronous execution of the preceding pipeline (i.e., the shell does
.I not\^
wait for that pipeline to finish).
The symbol
\f4\(bv&\f1
causes asynchronous execution of the preceding command or pipeline
with a two-way pipe established 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
\f4\-p\f1
option of
the special commands
\f4read\f1
and
\f4print\^\f1
described later.
The symbol
\f4&&\f1
\f1(\|\f4\(bv\|\(bv\f1\^)
causes the
.I list\^
following it to be executed only if the preceding
pipeline
returns a zero (non-zero) value.
An arbitrary number of new-lines may appear in a
.I list,\^
instead of a semicolon,
to delimit a command.
.PP
A
.I command\^
is either a simple-command
or one of the following.
Unless otherwise stated,
the value returned by a command is that of the
last simple-command executed in the command.
.TP
\f4for\fP \f2identifier\^\fP \*(OK \f4in\fP \f2word\^\fP .\|.\|. \*(CK \f4;do\fP \f2list\^\fP \f4;done\fP
Each time a
\f4for\f1
command is executed,
.I identifier\^
is set to the next
.I word\^
taken from the
\f4in\f1
.I word\^
list.
If
\f4in\f2 word\^\f1
\&.\|.\|.
is omitted, then
the
\f4for\f1
command executes the \f4do\fP \f2list\^\fP once for each positional parameter
that is set
(see
.I "Parameter Substitution\^"
below).
Execution ends when there are no more words in the list.
.TP
\f4select\fP \f2identifier\^\fP \*(OK \f4in\fP \f2word\^\fP .\|.\|. \*(CK \f4;do\fP \f2list\^\fP \f4;done\fP
A
\f4select\f1
command prints on standard error (file descriptor 2), the set of
.IR word s,
each preceded by a number.
If
\f4in\f2 word\^\f1
\&.\|.\|.
is omitted, then
the
positional parameters
are used instead
(see
.I "Parameter Substitution\^"
below).
The
\f4PS3\f1
prompt is printed
and a line is read from the standard input.
If this line consists of the number
of one of the listed
.IR word s,
then the value of the parameter
.I identifier\^
is set to the
.I word\^
corresponding to this number.
If this line is empty the selection list is
printed again.
Otherwise the value of the parameter
.I identifier\^
is set to
\f4null\fP.
The contents of the line read from standard input is
saved in
the variable
\f4REPLY.\f1
The
.I list\^
is executed for each selection until a
\f4break\^\f1
or
.I end-of-file\^
is encountered.
.TP
\f4case\fP \f2word\^\fP \f4in\fP \*(OK \*(OK\f4(\fP\*(CK\f2pattern\^\fP \*(OK \(bv \f2pattern\^\fP \*(CK .\|.\|. \f4)\fP \f2list\^\fP \f4;;\fP \*(CK .\|.\|. \f4esac\fP
A
\f4case\f1
command executes the
.I list\^
associated with the first
.I pattern\^
that matches
.IR word .
The form of the patterns is
the same as that used for
file-name generation (see
.I "File Name Generation\^"
below).
.ll +3
.TP
\f4if\fP \f2list\^\fP \f4;then\fP \f2list\^\fP \*(OK \
\f4elif\fP \f2list\^\fP \f4;then\fP \f2list\^\fP \*(CK .\|.\|. \
\*(OK \f4;else\fP \f2list\^\fP \*(CK \f4;f\&i\fP
.ll
The
.I list\^
following \f4if\fP is executed and,
if it
returns a zero exit status, the
.I list\^
following
the first
\f4then\f1
is executed.
Otherwise, the
.I list\^
following \f4elif\fP
is executed and, if its value is zero,
the
.I list\^
following
the next
\f4then\f1
is executed.
Failing that, the
\f4else\f1
.I list\^
is executed.
If no
\f4else\f1
.I list\^
or
\f4then\f1
.I list\^
is executed, then the
\f4if\f1
command returns a zero exit status.
.TP
.PD 0
\f4while\fP \f2list\^\fP \f4;do\fP \f2list\^\fP \f4;done\fP
.TP
\f4until\fP \f2list\^\fP \f4;do\fP \f2list\^\fP \f4;done\fP
.PD
A
\f4while\f1
command repeatedly executes the
\f4while\f1
.I list\^
and, if the exit status of the last command in the list is zero, executes
the
\f4do\f1
.IR list ;
otherwise the loop terminates.
If no commands in the
\f4do\f1
.I list\^
are executed, then the
\f4while\f1
command returns a zero exit status;
\f4until\f1
may be used in place of
\f4while\f1
to negate
the loop termination test.
.TP
\f4(\fP\f2list\^\fP\f4)\fP
.br
Execute
.I list\^
in a separate environment.
Note, that if two adjacent open parentheses are
needed for nesting, a space must be inserted to avoid
arithmetic evaluation as described below.
.TP
\f4{ \fP\f2list\^\fP\f4;}\fP
.br
.I list\^
is simply executed.
The \f4{\fP must be followed by a space.
Note that unlike the metacharacters
\f4(\f1
and
\f4)\f1,
\f4{\f1
and
\f4}\f1
are
.IR "reserved word" s
and must be typed
at the beginning of a line or after a
\f4;\f1
in order to be recognized.
.TP
\f4[[\fP\f2expression\^\fP\f4]]\fP
.br
Evaluates
.I expression\^
and returns a zero exit status when
.I expression\^
is true.
See
.I "Conditional Expressions\^"
below, for a description of
.IR expression.
.TP
.PD 0
\f4function\fP \f2identifier\^\fP \f4{ \fP\f2list\^\fP \f4;}\fP
.TP
\f2identifier\^\fP \f4() { \fP\f2list\^\fP \f4;}\fP
.PD
Define a function which is referenced by
.IR identifier .
The body of the function is the
.I list\^
of commands between
\f4{\f1
and
\f4}\f1.
(see
.I Functions\^
below).
The \f4{\fP must be followed by a space.
.TP
\f4time \fP\f2pipeline\^\fP
.br
The
.I pipeline\^
is executed and the elapsed time as well as
the user and system time are printed on standard error.
.PP
The following reserved words
are only recognized as the first word of a command
and when not quoted:
.if t .RS
.PP
.ft 4
.if n if then else elif fi case esac for while until do done { } function select time [[ ]]
.if t if   then   else   elif   fi   case   esac   for   while   until   do   done   {   }   function   select   time  [[  ]]
.ft 1
.if t .RE
.SS Comments.
A word beginning with
\f4#\f1
causes that word and all the following characters up to a new-line
to be ignored.
.SS Aliasing.
The first word of each command is replaced by the text of an
\f4alias\f1
if an
\f4alias\f1
for this word has been defined.
An alias name consists of any number of characters excluding meta-characters,
quoting characters, file expansion characters, parameter and command substitution
characters and \f4=\f1.
The replacement string can contain any
valid Shell script
including the metacharacters listed above.
The first word of each command in the
replaced text,
other than
any that are in the process of being replaced,
will be tested for aliases.
If the last character of the alias value is a
.I blank\^
then the word following the alias will also be checked for alias
substitution.
Aliases can be used to redefine special
builtin commands but cannot be used to redefine
the reserved words listed above.
Aliases can be created, listed, and exported with the
\f4alias\f1
command and can be removed with the
\f4unalias\f1
command.
Exported aliases remain in effect for
scripts invoked by name,
but must be reinitialized for separate invocations
of the Shell (see
.I Invocation\^
below).
.PP
.I Aliasing\^
is performed when
scripts are read,
not while they are executed.
Therefore,
for an alias to take effect
the
\f4alias\fP
definition command has to be executed before
the command which references the alias is read.
.PP
Aliases are frequently used as a short hand for full path
names.
An option to the aliasing facility allows the value of the alias
to be automatically set to the full pathname of
the corresponding command.
These aliases are called
.I tracked
aliases.
The value of a
.I tracked
alias is defined the first time the corresponding command
is looked up and becomes undefined each time
the
\f4PATH\f1
variable is reset.
These aliases remain
.I tracked
so that the next
subsequent reference will redefine the value.
Several tracked aliases are compiled into the shell.
The
\f4\-h\f1
option of the
\f4set\f1
command makes each referenced command name
into a tracked alias.
.PP
The following
.I exported aliases
are compiled into the shell
but can be unset or redefined:
.RS 20
.PD 0
.TP
\f4autoload=\(fmtypeset \-fu\(fm\f1
.TP
\f4false=\(fmlet 0\(fm\f1
.TP
\f4functions=\(fmtypeset \-f\(fm\f1
.TP
\f4hash=\(fmalias \-t\(fm\f1
.TP
\f4history=\(fmfc \-l\(fm\f1
.TP
\f4integer=\(fmtypeset \-i\(fm\f1
.TP
\f4nohup=\(fmnohup \(fm\f1
.TP
\f4r=\(fmfc \-e \-\(fm\f1
.TP
\f4true=\(fm:\(fm\f1
.TP
\f4type=\(fmwhence \-v\(fm\f1
.PD
.RE
.SS Tilde Substitution.
After alias substitution is performed, each word
is checked to see if it begins with an unquoted
\f4\(ap\f1.
If it does, then the word up to a
\f4/\f1
is checked to see if it matches a user name in the
\f4/etc/passwd\f1
file.
If a match is found, the
\f4\(ap\f1
and the matched login name is replaced by the
login directory of the matched user.
This is called a
.I tilde
substitution.
If no match is found, the original text is left unchanged.
A
\f4\(ap\f1
by itself, or in front of a
\f4/\f1,
is replaced by
\f4$HOME\fP.
A
\f4\(ap\f1
followed by a
\f4+\f1
or
\f4\-\f1
is replaced by
\f4$PWD\fP
and
\f4$OLDPWD\fP
respectively.
.PP
In addition,
.I tilde
substitution is attempted when
the value of a
.I "variable assignment"
begins with a
\f4\(ap\f1.
.SS Command Substitution.
The standard output from a command enclosed in
parentheses preceded by a dollar sign (
\f4$(\|)\f1
)
or a pair of grave accents (\^\f4\*`\^\*`\fP\^)
may be used as part or all
of a word;
trailing new-lines are removed.
In the second (archaic) form, the string between the quotes is processed
for special quoting characters before the command is executed (see
.I Quoting\^
below).
The command substitution
\^\f4$(\^cat file\^)\fP\^
can be replaced by the equivalent but faster
\^\f4$(\^<file\^)\fP\^.
Command substitution of most special commands
that do not perform input/output redirection are
carried out without creating a separate process.
.PP
An arithmetic expression enclosed in double parentheses
and preceded by a dollar sign [\f4$(())\f1] is replaced
by the value of the arithmetic expression within the double parentheses.
.SS Parameter Substitution.
A
.I parameter\^
is an
.IR identifier ,
one or more digits,
or any of the characters
\f4\(**\f1,
\f4@\f1,
\f4#\f1,
\f4?\f1,
\f4\-\f1,
\f4$\f1,
and
\f4!\^\f1.
A
.I variable\^
(a parameter denoted by an identifier)
has a
.I value\^
and zero or more
.IR attributes .
.I Variables \^
can be assigned
\f4values\fP
and
.I attributes
by using the
\f4typeset\^\f1
special command.
The attributes supported by the Shell are described
later with the
\f4typeset\^\f1
special command.
Exported parameters pass values and attributes to
the environment.
.PP
The shell supports a one-dimensional array facility.
An element of an array variable is referenced by a
.IR subscript .
A
.I subscript\^
is denoted by a
\f4[\f1,
followed by an
.I arithmetic expression\^
(see
.I "Arithmetic Evaluation"
below) followed by a
\f4]\f1.
To assign values to an array, use
\f4set \-A\fP \f2name\fP  \f2value\fP .\|.\|. .
The value of all
subscripts must be in the
range of
0 through 1023.
Arrays need not be declared.
Any reference to a variable
with a valid subscript is
legal and an array will be created if necessary.
Referencing an array without a subscript
is equivalent to referencing the element zero.
.PP
The
.I value\^
of a
.I variable\^
may also be assigned by writing:
.RS
.PP
\f2name\f4=\f2value\^\|\f1
\*(OK
\f2name\f4=\f2value\^\f1
\*(CK .\|.\|.
.RE
.PP
.PD 0
If the integer attribute,
\f4\-i\f1,
is set for
.I name\^
the
.I value\^
is subject to arithmetic evaluation as described below.
.PP
Positional parameters,
parameters denoted by a number,
may be assigned values with the
\f4set\^\f1
special command.
Parameter
\f4$0\f1
is set from argument zero when the shell
is invoked.
.PP
The character
\f4$\f1
is used to introduce substitutable
.IR parameters .
.TP
\f4${\fP\f2parameter\^\fP\f4}\fP
The shell
reads all the characters from
\f4${\f1
to the matching
\f4}\f1
as part of the same word even if it contains
braces or metacharacters.
The value, if any, of the parameter is substituted.
The braces are required when
.I parameter\^
is followed by a letter, digit, or underscore
that is not to be interpreted as part of its name
or when a variable is subscripted.
If
.I parameter\^
is one or more digits then it is a positional parameter.
A positional parameter of more than one digit must be
enclosed in braces.
If
.I parameter\^
is
\f4\(**\f1
or
\f4@\f1,
then all the positional
parameters, starting with
\f4$1\f1,
are substituted
(separated by a field separator character).
If an array
.I identifier\^
with subscript
\f4\(**\f1
or
\f4@\f1
is used,
then the value
for each of the
elements
is substituted
(separated by a field separator character).
.TP
\f4${#\fP\f2parameter\^\fP\f4}\fP
If
.I parameter\^
is
\f4\(**\f1
or
\f4@\f1,
the number of positional parameters is substituted.
Otherwise, the length of the value of the
.I parameter\^
is substituted.
.TP
\f4${#\fP\f2identifier\fP\f4[*]}\fP
The number of elements in the array
.I identifier\^
is substituted.
.TP
\f4${\fP\f2parameter\^\fP\f4:\-\fP\f2word\^\fP\f4}\fP
If
.I parameter\^
is set and is non-null then substitute its value;
otherwise substitute
.IR word .
.TP
\f4${\fP\f2parameter\^\fP\f4:=\fP\f2word\^\fP\f4}\fP
If
.I parameter\^
is not set or is null then set it to
.IR word ;
the value of the parameter is then substituted.
Positional parameters may not be assigned to
in this way.
.TP
\f4${\fP\f2parameter\^\fP\f4:?\fP\f2word\^\fP\f4}\fP
If
.I parameter\^
is set and is non-null then substitute its value;
otherwise, print
.I word\^
and exit from the shell.
If
.I word\^
is omitted then a standard message is printed.
.TP
\f4${\fP\f2parameter\^\fP\f4:+\fP\f2word\^\fP\f4}\fP
If
.I parameter\^
is set and is non-null then substitute
.IR word ;
otherwise substitute nothing.
.TP
.PD 0
\f4${\fP\f2parameter\^\fP\f4#\fP\f2pattern\^\fP\f4}\fP
.TP
\f4${\fP\f2parameter\^\fP\f4##\fP\f2pattern\^\fP\f4}\fP
.PD
If
the Shell
.I pattern\^
matches the beginning of the value of
.IR parameter ,
then the value of
this substitution is the value of the
.I parameter\^
with the matched portion deleted;
otherwise the value of this
.I parameter\^
is substituted.
In the first form the smallest matching pattern is deleted and in the
second form the largest matching pattern is deleted.
.TP
.PD 0
\f4${\fP\f2parameter\^\fP\f4%\fP\f2pattern\^\fP\f4}\fP
.TP
\f4${\fP\f2parameter\^\fP\f4%%\fP\f2pattern\^\fP\f4}\fP
.PD
If
the Shell
.I pattern\^
matches the end of the value of
.IR parameter ,
then the value of
this substitution is the value of the
.I parameter\^
with the matched part deleted;
otherwise substitute the value of
.IR parameter .
In the first form the smallest matching pattern is deleted and in the
second form the largest matching pattern is deleted.
.PD
.PP
In the above,
.I word\^
is not evaluated unless it is
to be used as the substituted string,
so that, in the following example,
\f4pwd\^\f1
is executed only if
\f4d\^\f1
is not set or is null:
.RS
.PP
echo \|${d:\-\^$(\^pwd\^)\^}
.RE
.PP
If the colon (
\f4: )\f1
is omitted from the above expressions,
then the shell only checks whether
.I parameter\^
is set or not.
.PP
The following
parameters
are automatically set by the shell:
.RS
.PD 0
.TP
\f4#\f1
The number of positional parameters in decimal.
.TP
\f4\-\f1
Flags supplied to the shell on invocation or by
the
\f4set\f1
command.
.TP
\f4?\f1
The decimal value returned by the last executed command.
.TP
\f4$\f1
The process number of this shell.
.TP
\f4_\f1
Initially, the value
\f4_\f1
is an absolute pathname of the shell or script being executed
as passed in the
.IR environment .
Subsequently it is assigned the last argument of the previous command.
This parameter is not set for commands which are asynchronous.
This parameter is also used to hold the name of the matching
\f4MAIL\fP
file when checking for mail.
.TP
\f4!\f1
The process number of the last background command invoked.
.TP
\f4ERRNO\fP
The value of
.I errno
as set by the most recently failed system call.
This value
is system dependent and is intended for debugging purposes.
.TP
\f4LINENO\fP
The line number of the current line within the script or
function being executed.
.TP
\f4OLDPWD\fP
The previous working directory set by the
\f4cd\f1
command.
.TP
\f4OPTARG\fP
The value of the last option argument processed by the
\f4getopts\f1
special command.
.TP
\f4OPTIND\fP
The index of the last option argument processed by the
\f4getopts\f1
special command.
.TP
\f4PPID\fP
The process number of the parent of the shell.
.TP
\f4PWD\fP
The present working directory set by the
\f4cd\f1
command.
.TP
\f4RANDOM\fP
Each time this variable is referenced, a random integer,
uniformly distributed between 0 and 32767, is generated.
The sequence of random numbers can be initialized by assigning
a numeric value to
\f4RANDOM\f1.
.TP
\f4REPLY\fP
This variable is set by the
\f4select\f1
statement and by
the
\f4read\f1
special command when no arguments are supplied.
.TP
\f4SECONDS\fP
Each time this variable is referenced, the number of
seconds since shell invocation is returned.
If this variable is
assigned a value, then the value returned upon reference will
be the value that was assigned plus the number of seconds since the assignment.
.PD
.RE
.PP
The following
variables
are used by the shell:
.RS
.PD 0
.TP
\f4CDPATH\fP
The search path for the
\f4cd\fP
command.
.TP
\f4COLUMNS\fP
If this variable is set,
the value is used to define the width of the edit window
for the shell edit modes and for printing
\f4select\f1
lists.
.TP
\f4EDITOR\fP
If the value of this variable ends in
.\" the next three lines were commented out because AT&T does not support emacs
.\".IR emacs ,
.\".IR gmacs ,
.\"or
\f4vi\fP
and the
\f4VISUAL\fP
variable is not set,
then the corresponding option
(see
.I "Special Command"
\f4set\f1
below)
will be turned on.
.TP
\f4ENV\f1
If this variable is set, then
parameter substitution is performed on
the value to generate
the pathname of the script that will be
executed when the
.I shell\^
is invoked
(see
.I Invocation\^
below).
This file is typically used for
.I alias
and
.I function
definitions.
.TP
\f4FCEDIT\fP
The default editor name for the
\f4fc\f1
command.
.TP
\f4FPATH\f1
The search path for function definitions.
This path is searched when a function with the
\f4\-u\f1
attribute is referenced and when a command is not found.
If an executable file is found, then it is read and executed
in the current environment.
.TP
\f4IFS\f1
Internal field separators,
normally
\f4space\f1,
\f4tab\f1,
and
\f4new-line\f1
that is used to separate command words which result from
command or parameter substitution
and for separating words with the special command
\f4read\f1.
The first character of the
\f4IFS\f1
variable is used to separate arguments for the
\f4"$\(**"\fP
substitution (see
.I Quoting
below).
.TP
\f4HISTFILE\f1
If this variable is set when the shell is invoked, then
the value is the pathname of the file that will be
used to store the command history
(see
.I "Command re-entry\^"
below).
.TP
\f4HISTSIZE\f1
If this variable is set when the shell is invoked, then
the number of previously entered commands that
are accessible by this shell
will be greater than or equal to this number.
The default is 128.
.TP
\f4HOME\fP
The default argument (home directory) for the
\f4cd\f1
command.
.TP
\f4LINES\fP
If this variable is set,
the value is used to determine the column length for printing
\f4select\f1
lists.
Select lists will print vertically until about two-thirds of
\f4LINES\fP
lines are filled.
.TP
\f4MAIL\fP
If this variable is set to the name of a mail file
.I and\^
the
\f4MAILPATH\fP
variable is not set,
then the shell informs the user of arrival of mail
in the specified file.
.TP
\f4MAILCHECK\fP
This variable specifies how often (in seconds) the
shell will check for changes in the modification time
of any of the files specified by the
\f4MAILPATH\fP
or
\f4MAIL\fP
variables.
The default value is 600 seconds.
When the time has elapsed
the shell will check before issuing the next prompt.
.TP
\f4MAILPATH\fP
A colon (
\f4:\f1
)
separated list of file names.
If this variable is set
then the shell informs the user of
any modifications to the specified files
that have occurred within the last
\f4MAILCHECK\fP
seconds.
Each file name can be followed by a
\f4?\f1
and a message that will be printed.
The message will undergo parameter substitution
with the variable,
\f4$_\f1
defined as the name of the file that has changed.
The default message is
.I you have mail in $_\^.
.TP
\f4PATH\fP
The search path for commands (see
.I Execution\^
below).
The user may not change
\f4PATH\f1
if executing under
.I rksh
(except in \f2.profile\f1).
.TP
\f4PS1\f1
The value of this variable is expanded for parameter
substitution to define the
primary prompt string which by default is
\f1``\f4$ \|\f1''.
The character
\f4!\f1
in the primary prompt string is replaced by the
.I command\^
number (see
.I Command Re-entry
below).
.TP
\f4PS2\f1
Secondary prompt string, by default
\f1``\f4> \|\f1''.
.TP
\f4PS3\f1
Selection prompt string
used within a
\f4select\f1
loop, by default
\f1``\f4#? \|\f1''.
.TP
\f4PS4\f1
The value of this variable is expanded for parameter
substitution and precedes each line of an execution trace.
If omitted, the execution trace prompt is
\f1``\f4+ \|\f1''.
.TP
\f4SHELL\f1
The pathname of the
.I shell\^
is kept in the environment.
At invocation, if the basename of this variable matches the pattern
\f4*r*sh\f1,
then the shell becomes restricted.
.TP
\f4TMOUT\fP
If set to a value greater than zero,
the shell will terminate if a command is not entered within
the prescribed number of seconds after issuing the
\f4PS1\fP
prompt.
(Note that the shell can be compiled with a maximum bound
for this value which cannot be exceeded.)
.TP
\f4VISUAL\fP
If the value of this variable ends in
.\"
.\" the next three lines were commented out because AT&T does not support emacs
.\".IR emacs ,
.\".IR gmacs ,
.\"or
\f4vi\fP
then the corresponding option
(see
.I "Special Command"
\f4set\f1
below)
will be turned on.
.PD
.RE
.PP
The shell gives default values to
\f4PATH\fP, \f4PS1\fP, \f4PS2\fP, \f4MAILCHECK\fP,
\f4TMOUT\fP and \f4IFS\fP.
\f4HOME\f1, \f4MAIL\f1 and \f4SHELL\f1
are set by \f4login\fP(1).
.SS Blank Interpretation.
After parameter and command substitution,
the results of substitutions are scanned for the field separator
characters (
those found in
\f4IFS\f1
)
and split into distinct arguments where such characters are found.
Explicit null arguments (\^\f4"\^"\fP or \f4\*\(fm\^\*\(fm\fP\^) are retained.
Implicit null arguments
(those resulting from
.I parameters\^
that have no values) are removed.
.SS File Name Generation.
Following substitution, each command
.I word\^
is scanned for
the characters
\f4\(**\f1,
\f4?\f1,
and
\f4\*(OK\^\f1
unless the
\f4\-f\f1
option has been
\f4set\f1.
If one of these characters appears
then the word is regarded as a
.IR pattern .
The word is replaced with lexicographically sorted file names that match the pattern.
If no file name is found that matches the pattern, then
the word is left unchanged.
When a
.I pattern\^
is used for file name generation,
the character \f4.\f1
at the start of a file name
or immediately following a
\f4/\f1,
as well as the character
\f4/\f1
itself,
must be matched explicitly.
In other instances of pattern matching the
\f4/\f1
and \f4.\f1
are not treated specially.
.PP
.PD 0
.RS
.TP
\f4\(**\f1
Matches any string, including the null string.
.TP
\f4?\f1
Matches any single character.
.TP
\f4\*(OK\f1\^.\|.\|.\^\f4\*(CK\f1
Matches any one of the enclosed characters.
A pair of characters separated by
\f4\-\f1
matches any
character lexically between the pair, inclusive.
If the first character following the opening "[ \|"
is a "!\|" then any character not enclosed is matched.
A
\f4\-\f1
can be included in the character set by putting it as the
first or last character.
.PD
.RE
A
.I pattern-list
is a list of one or more patterns separated from each other
with a
\f4\(bv\f1.
Composite patterns can be formed with one or more of the following:
.PD 0
.RS
.TP
\f4?(\fP\f2pattern-list\^\fP\f4)\fP
Optionally matches any one of the given patterns.
.TP
\f4*(\fP\f2pattern-list\^\fP\f4)\fP
Matches zero or more occurrences of the given patterns.
.TP
\f4+(\fP\f2pattern-list\^\fP\f4)\fP
Matches one or more occurrences of the given patterns.
.TP
\f4\&@\&(\fP\f2pattern-list\^\fP\f4)\fP
Matches exactly one of the given patterns.
.TP
\f4!(\fP\f2pattern-list\^\fP\f4)\fP
Matches anything, except one of the given patterns.
.PD
.RE
.SS Quoting.
Each of the
.I metacharacters\^
listed above (see
.I Definitions
above)
has a special meaning to the shell
and causes termination of a word unless quoted.
A character may be
.I quoted\^
(i.e., made to stand for itself)
by preceding
it with a
\f4\e\f1.
The pair
\f4\enew-line\f1
is removed.
All characters enclosed between a pair of single quote marks (\^\f4\(fm\^\(fm\fP\^),
are quoted.
A single quote cannot appear within single quotes.
Inside double quote marks
(\f4"\^"\fP),
parameter and command substitution occurs and
\f4\e\f1
quotes the characters
\f4\e\f1,
\f4\*`\f1,
\f4"\fP,
and
\f4$\f1.
The meaning of
\f4$\(**\f1
and
\f4$@\f1
is identical when not quoted or when used as a variable assignment value
or as a file name.
However, when used as a command argument,
\f4"$\(**"\fP
is equivalent to
\f4"$1\fP\f2d\fP\f4\|$2\fP\f2d\fP\|.\|.\|.\f4"\fP,
where
.I d
is the first character of the
\f4IFS\f1
variable, whereas
\f4"$@"\fP
is equivalent to
\f4"$1"\f2d\f4"$2"\f2d\f4...\f1
Inside grave quote marks
(\f4\*`\^\*`\fP)
\f4\e\f1
quotes the characters
\f4\e\f1,
\f4\*`\f1,
and
\f4$\f1.
If the grave quotes occur within double quotes then
\f4\e\f1
also quotes the character
\f4"\fP.
.PP
The special meaning of reserved words or aliases can be removed by quoting any
character of the reserved word.
The recognition of function names or special command names listed below
cannot be altered by quoting them.
.SS Arithmetic Evaluation.
An ability to perform integer arithmetic
is provided with the special command
\f4let\f1.
Evaluations are performed using
.I long\^
arithmetic.
Constants are of the form
\*(OK\f2base\f4#\^\f1\*(CK\f2n\^\fP
where
.I base\^
is a decimal number between two and thirty-six
representing the arithmetic base
and
.I n\^
is a number in that base.
If
\f2base\f4#\^\f1
is omitted
then base 10 is used.
.PP
An arithmetic expression uses the same syntax, precedence, and
associativity of
expression of the C language.
All the integral operators,
other than
\f4++\f1,
\f4\-\|\-\f1,
\f4?:\f1,
and
\f4,\f1
are supported.
Variables can be referenced by name within an arithmetic expression
without using the parameter substitution syntax.
When a variable is referenced, its value is evaluated as
an arithmetic expression. 
.PP
An internal integer representation of a
.I variable\^
can be specified with the
\f4\-i\f1
option of the
\f4typeset\f1
special command.
Arithmetic evaluation is performed on the value of each
assignment to a variable with the
\f4\-i\f1
attribute.
If you do not specify an arithmetic base,
the first assignment to the
variable determines the arithmetic base.
This base is
used when
parameter substitution occurs.
.PP
Since many of the arithmetic operators require
quoting, an alternative form of the
\f4let\f1
command is provided.
For any command which begins with a
\f4((\f1,
all the characters until a matching
\f4))\f1
are treated as a quoted expression.
More precisely,
\f4((\f1.\|.\|.\f4))\f1
is equivalent to
\f4let\^\f1
\f4"\fP\|.\|.\|.\f4"\fP.
.SS Prompting.
When used interactively,
the shell prompts with the parameter expanded value of
\f4PS1\f1
before reading a command.
If at any time a new-line is typed and further input is needed
to complete a command, then the secondary prompt
(i.e., the value of
\f4PS2\f1)
is issued.
.SS Conditional Expressions.
A
.I "conditional expression"
is used with the
\f4[[\f1
compound command to test attributes of files and to compare
strings.
Word splitting and file name generation are
not performed on the words between
\f4[[\f1
and
\f4]]\f1.
Each expression can be constructed from one or more
of the following unary or binary expressions:
.PD 0
.TP 1i
\f4\-a\fP \f2file\fP
True, if
.I file
exists.
.TP
\f4\-b\fP \f2file\fP
True, if
.I file
exists and is a block special file.
.TP
\f4\-c\fP \f2file\fP
True, if
.I file
exists and is a character special file.
.TP
\f4\-d\fP \f2file\fP
True, if
.I file
exists and is a directory.
.TP
\f4\-f\fP \f2file\fP
True, if
.I file
exists and is an ordinary file.
.TP
\f4\-g\fP \f2file\fP
True, if
.I file
exists and is has its setgid bit set.
.TP
\f4\-k\fP \f2file\fP
True, if
.I file
exists and is has its sticky bit set.
.TP
\f4\-n\fP \f2string\fP
True, if length of
.I string
is non-zero.
.TP
\f4\-o\fP \f2option\fP
True, if option named
.I option
is on.
.TP
\f4\-p\fP \f2file\fP
True, if
.I file
exists and is a fifo special file or a pipe.
.TP
\f4\-r\fP \f2file\fP
True, if
.I file
exists and is readable by current process.
.TP
\f4\-s\fP \f2file\fP
True, if
.I file
exists and has size greater than zero.
.TP
\f4\-t\fP \f2fildes\fP
True, if file descriptor number
.I fildes
is open and associated with a terminal device.
.TP
\f4\-u\fP \f2file\fP
True, if
.I file
exists and is has its setuid bit set.
.TP
\f4\-w\fP \f2file\fP
True, if
.I file
exists and is writable by current process.
.TP
\f4\-x\fP \f2file\fP
True, if
.I file
exists and is executable by current process.
If
.I file
exists and is a directory, then the current process
has permission to search in the directory.
.TP
\f4\-z\fP \f2string\fP
True, if length of
.I string
is zero.
.TP
\f4\-L\fP \f2file\fP
True, if
.I file
exists and is a symbolic link.
.TP
\f4\-O\fP \f2file\fP
True, if
.I file
exists and is owned by the effective user id of this process.
.TP
\f4\-G\fP \f2file\fP
True, if
.I file
exists and its group matches the effective group id of this process.
.TP
\f4\-S\fP \f2file\fP
True, if
.I file
exists and is a socket.
.TP
\f2file1\fP \f4\-nt\fP \f2file2\fP
True, if
.I file1
exists and is newer than
.IR file2 .
.TP
\f2file1\fP \f4\-ot\fP \f2file2\fP
True, if
.I file1
exists and is older than
.IR file2 .
.TP
\f2file1\fP \f4\-ef\fP \f2file2\fP
True, if
.I file1
and 
.I file2
exist and refer to the same file.
.TP
\f2string\fP \f4=\fP \f2pattern\fP
True, if
.I string
matches
.IR pattern .
.TP
\f2string\fP \f4!=\fP \f2pattern\fP
True, if
.I string
does not match
.IR pattern .
.TP
\f2string1\fP \f4<\fP \f2string2\fP
True, if
.I string1
comes before
.I string2
based on ASCII value of their characters.
.TP
\f2string1\fP \f4>\fP \f2string2\fP
True, if
.I string1
comes after
.I string2
based on ASCII value of their characters.
.TP
\f2exp1\fP \f4\-eq\fP \f2exp2\fP
True, if
.I exp1
is equal to
.IR exp2.
.TP
\f2exp1\fP \f4\-ne\fP \f2exp2\fP
True, if
.I exp1
is not equal to
.IR exp2.
.TP
\f2exp1\fP \f4\-lt\fP \f2exp2\fP
True, if
.I exp1
is less than
.IR exp2.
.TP
\f2exp1\fP \f4\-gt\fP \f2exp2\fP
True, if
.I exp1
is greater than
.IR exp2.
.TP
\f2exp1\fP \f4\-le\fP \f2exp2\fP
True, if
.I exp1
is less than or equal to
.IR exp2.
.TP
\f2exp1\fP \f4\-ge\fP \f2exp2\fP
True, if
.I exp1
is greater than or equal to
.IR exp2.
.PD
.PP
In each of the above expressions, if
.I file
is of the form
\f4/dev/fd/\fP\f2n\fP,
where
.I n
is an integer,
then the test applied to the open file whose
descriptor number is
.IR n .
.PP
A compound expression can be constructed from these primitives by
using any of the following, listed in decreasing order of precedence.
.PD 0
.TP
\f4(\fP\f2expression\fP\f4)\fP
True, if
.I expression
is true.
Used to group expressions.
.TP
\f4!\fP \f2expression\fP
True if
.I expression
is false.
.TP
\f2expression1\fP \f4&&\fP \f2expression2\fP
True, if
.I expression1
and
.I expression2
are both true.
.TP
\f2expression1\fP \f4\(bv\(bv\fP \f2expression2\fP
True, if either
.I expression1
or
.I expression2
is true.
.PD
.SS Input/Output.
Before a command is executed, its input and output
may be redirected using a special notation interpreted by the shell.
The following may appear anywhere in a simple-command
or may precede or follow a
.I command\^
and are
.I not\^
passed on to the invoked command.
Command and parameter substitution occurs before
.I word\^
or
.I digit\^
is used except as noted below.
File name generation
occurs only if the pattern matches a single file
and blank interpretation is not performed.
.TP 14
\f4<\f2word\f1
Use file
.I word\^
as standard input (file descriptor 0).
.TP
\f4>\f2word\f1
Use file
.I word\^
as standard output (file descriptor 1).
If the file does not exist then it is created.
If the file exists, is a regular file, and the
\f4noclobber\f1 option is on, this causes an error;
otherwise, it is truncated to zero length.
.TP
\f4>|\f2word\f1
Sames as
\f4>\f1,
except that it overrides the
\f4noclobber\f1
option.
.TP
\f4>>\f2word\f1
Use file
.I word\^
as standard output.
If the file exists then output is appended to it (by first seeking to the end-of-file);
otherwise, the file is created.
.TP
\f4<>\f2word\f1
Open file
.I word\^
for reading and writing
as standard input.
.TP
\f4<<\fP\*(OK\f4\-\fP\*(CK\f2word\fP
The shell input is read up to a line that is the same as
.IR word ,
or to an end-of-file.
No parameter substitution, command substitution or
file name generation is performed on
.IR word .
The resulting document,
called a
.IR here-document ,
becomes
the standard input.
If any character of
.I word\^
is quoted, then no interpretation
is placed upon the characters of the document;
otherwise, parameter and command substitution occurs,
\f4\enew-line\f1
is ignored,
and
\f4\e\f1
must be used to quote the characters
\f4\e\f1,
\f4$\f1,
\f4\*`\f1,
and the first character of
.IR word .
If
\f4\-\f1
is appended to
\f4<<\f1,
then all leading tabs are stripped from
.I word\^
and from the document.
.TP
\f4<&\f2digit\f1
The standard input is duplicated from file descriptor
.I digit
[see
\f4dup\fP(2)].
Similarly for the standard output using
\f4>&\f1
.IR digit .
.TP
\f4<&\-\f1
The standard input is closed.
Similarly for the standard output using
\f4>&\-\f1.
.TP
\f4<&p\f1
The input from the co-process is moved to standard input.
.TP
\f4>&p\f1
The output to the co-process is moved to standard output.
.PP
If one of the above is preceded by a digit,
then the
file descriptor number referred to is that specified
by the digit
(instead of the default 0 or 1).
For example:
.RS
.PP
\&.\|.\|. \|2>&1
.RE
.PP
means file descriptor 2 is to be opened
for writing as a duplicate
of file descriptor 1.
.PP
The order in which redirections are specified is significant.
The shell evaluates each redirection in terms of the
.RI ( "file descriptor" ", " file )
association at the time of evaluation.
For example:
.RS
.PP
\&.\|.\|. \|1>\f2fname\^\fP 2>&1
.RE
.PP
first associates file descriptor 1 with file
.IR fname\^ .
It then associates file descriptor 2 with the file associated with file
descriptor 1 (i.e.
.IR fname\^ ).
If the order of redirections were reversed, file descriptor 2 would be associated
with the terminal (assuming file descriptor 1 had been) and then file descriptor
1 would be associated with file
.IR fname\^ .
.PP
If a command is followed by
\f4&\f1
and job control is not active,
then the default standard input
for the command
is the empty file
\f4/dev/null\f1.
Otherwise, the environment for the execution of a command contains the
file descriptors of the invoking shell as modified by
input/output specifications.
.SS Environment.
The
.I environment\^
[see
\f4environ\fP(5)]
is a list of name-value pairs that is passed to
an executed program in the same way as a normal argument list.
The names must be
.I identifiers\^
and the values are character strings.
The shell interacts with the environment in several ways.
On invocation, the shell scans the environment
and creates a variable for each name found,
giving it the corresponding value and marking it
.I export .
Executed commands inherit the environment.
If the user modifies the values of these
variables or creates new ones, using the
\f4export\f1 or \f4typeset \-x\f1
commands they become part of the environment.
The environment seen by any executed command is thus composed
of any name-value pairs originally inherited by the shell,
whose values may be modified by the current shell,
plus any additions
which must be noted in
\f4export\f1
or
\f4typeset \-x\f1
commands.
.PP
The environment for any
.I simple-command\^
or function
may be augmented by prefixing it with one or more variable assignments.
A variable assignment argument is a word of the form
.IR identifier=value .
Thus:
.RS
.PP
\f4TERM=450 \|\f2cmd \|args\f1				and
.br
\f4(export \|TERM; \|TERM=450; \|\f2cmd \|args\f4)\f1
.RE
.PP
are equivalent (as far as the above execution of
.I cmd\^
is concerned except for commands listed with one or two daggers, \(dg, in the
Special Commands section).
.PP
If the
\f4\-k\f1
flag is set,
.I all\^
variable assignment arguments are placed in the environment,
even if they occur after the command name.
The following
first prints
\f4a=b c\f1
and then
\f4c:\f1
.PP
.RS
.nf
\f4echo a=b c
set \-k
echo a=b c\f1
.fi
.RE
This feature is intended for use with scripts written
for early versions of the shell and its use in new scripts
is strongly discouraged.
It is likely to disappear someday.
.SS Functions.
.PP
The
\f4function\^\f1
reserved word, described in the
.I Commands
section above,
is used to define shell functions.
Shell functions are read in and stored internally.
Alias names are resolved when the function is read.
Functions are executed like commands with the arguments
passed as positional parameters
(see
.I Execution
below).
.PP
Functions execute in the same process as the caller and
share all files
and present working directory with the
caller.
Traps caught by the caller are reset to their default action
inside the function.
A trap condition that is not caught or ignored by the
function causes the function to terminate and the condition
to be passed on to the caller.
A trap on
\f4EXIT\f1
set inside a function
is executed after the function completes in the environment
of the caller.
Ordinarily,
variables are shared between the calling program
and the function.
However,
the
\f4typeset\f1
special command used within a function
defines local variables whose scope includes
the current function and
all functions it calls.
.PP
The special command
\f4return\f1
is used to return
from function calls.
Errors within functions return control to the caller.
.PP
Function identifiers
can be listed with the
\f4\-f\f1
or
\f4+f\f1
option of the
\f4typeset\f1
special command.
The text of functions may also
be listed with
\f4\-f\f1.
Function can be undefined with the
\f4\-f\f1
option of the
\f4unset\f1
special command.
.PP
Ordinarily,
functions are unset when the shell executes a shell script.
The
\f4\-xf\f1
option of the
\f4typeset\f1
command allows a function to be exported
to scripts that are executed without a separate
invocation of the shell.
Functions that need to be defined across separate
invocations of the shell should be specified in the
\f4ENV\fP
file with the 
\f4\-xf\f1
option of
\f4typeset\f1.
.SS Jobs.
.PP
If the
\f4monitor\f1
option of the
\f4set\f1
command is turned on,
an interactive shell associates a \f2job\f1 with each pipeline.
It keeps a table of current jobs, printed by the
\f4jobs\f1
command, and assigns them small integer numbers.
When a job is started asynchronously with
\f4&\f1,
the shell prints a line which looks like:
.PP
.DT
	[1] 1234
.PP
indicating that the job which was started asynchronously was job number
1 and had one (top-level) process, whose process id was 1234.
.PP
If you are running a job and wish to do something else you may hit the key
\f4^Z\f1 (ctrl-z) which sends a STOP signal to the current job.
The shell will then normally indicate that the job has been `Stopped',
and print another prompt.
You can then manipulate the state of this job,
putting it in the background with the
\f4bg\f1
command, or run some other
commands and then eventually bring the job back into the foreground with
the foreground command
\f4fg\f1.
A \f4^Z\f1 takes effect immediately and
is like an interrupt in that pending output and unread input are discarded
when it is typed.
.PP
A job being run in the background will stop if it tries to read
from the terminal.
Background jobs are normally allowed to produce output,
but this can be disabled by giving the command ``stty tostop''.
If you set this
tty option, then background jobs will stop when they try to produce
output like they do when they try to read input.
.PP
There are several ways to refer to jobs in the shell.
A job can be referred to by the process id of any process of the job
or by one of the following:
.PD 0
.TP
\f4%\f2number\f1
The job with the given number.
.TP
\f4%\f2string\f1
Any job whose command line begins with
.IR string .
.TP
\f4%?\f2string\f1
Any job whose command line contains
.IR string .
.TP
\f4%%\f1
Current job.
.TP
\f4%+\f1
Equivalent to
\f4%%\f1.
.TP
\f4%\-\f1
Previous job.
.PD
.PP
This shell learns immediately whenever a process changes state.
It normally informs you whenever a job becomes blocked so that
no further progress is possible, but only just before it prints
a prompt.
This is done so that it does not otherwise disturb your work.
.PP
When the monitor mode is on, each background job that completes
triggers any trap set for
\f4CHLD\f1.
.PP
When you try to leave the shell while jobs are running or stopped, you will
be warned that `You have stopped(running) jobs.'
You may use the
\f4jobs\f1
command to see what they are.
If you do this or immediately try to
exit again, the shell will not warn you a second time, and the stopped
jobs will be terminated.
.SS Signals.
The INT and QUIT signals for an invoked
command are ignored if the command is followed by
\f4&\f1
and job
\f4monitor\f1
option is not active.
Otherwise, signals have the values
inherited by the shell from its parent
(but see also
the
\f4trap\f1
command below).
.SS Execution.
Each time a command is executed, the above substitutions
are carried out.
If the command name matches one
of the
.I "Special Commands\^"
listed below,
it is executed within the
current shell process.
Next, the command name is checked to see if
it matches one of the user defined functions.
If it does,
the positional parameters are saved
and then reset to the arguments of the
.I function\^
call.
When the
.I function\^
completes or issues a
\f4return\f1,
the positional parameter list is restored
and any trap set on
\f4EXIT\f1
within the function is executed.
The value of a
.I function\^
is the value of the last command executed.
A function is also executed in the
current shell process.
If a command name is not a
.I "special command\^"
or a user defined
.IR function ,
a process is created and
an attempt is made to execute the command via
\f4exec\fP(2).
.PP
The shell variable
\f4PATH\fP
defines the search path for
the directory containing the command.
Alternative directory names are separated by
a colon
\f1(\f4:\f1).
The default path is
\f4/usr/bin:\f1
(specifying
\f4/usr/bin\f1
and the current directory
in that order).
The current directory can be specified by
two or more adjacent colons, or by a colon
at the beginning or end of the path list.
If the command name contains a \f4/\fP then the search path
is not used.
Otherwise, each directory in the path is
searched for an executable file.
If the file has execute permission but is not a
directory or an
\f4a.out\f1
file,
it is assumed to be a file containing shell commands.
A sub-shell is spawned to read it.
All non-exported aliases,
functions,
and variables, are removed in this case.
A parenthesized command is executed in
a sub-shell without removing non-exported quantities.
.SS Command Re-entry.
The text of the last
\f4HISTSIZE\fP
(default 128)
commands entered from a terminal device
is saved in a
.I history
file.
The file
\f4$HOME/.sh_history\f1
is used if the file denoted by the
\f4HISTFILE\fP
variable is not set
or is not writable.
A shell can access the commands of
all
.I interactive
shells which use the same named
\f4HISTFILE\f1.
The special command
\f4fc\^\f1
is used to list or
edit a portion of this file.
The portion of the file to be edited or listed can be selected by
number or by giving the first character or
characters of the command.
A single command or range of commands can be specified.
If you do not specify an editor program as
an argument to
\f4fc\^\f1
then the value of the variable
\f4FCEDIT\f1
is used.
If
\f4FCEDIT\f1
is not defined then
\f4/usr/bin/ed\f1
is used.
The edited command(s) is printed and re-executed upon
leaving the editor.
The editor name
\f4\-\f1
is used to skip the editing phase and
to re-execute the command.
In this case a substitution variable of the form
\f2old\fP\f4=\fP\f2new\fP
can be used to modify the command before execution.
For example, if
\f4r\f1
is aliased to
\f4\(fmfc \-e \-\(fm\f1
then typing
`\f4r bad=good c\fP'
will re-execute the most recent command which starts with the letter
\f4c\f1,
replacing the first occurrence of the string
\f4bad\f1
with the string
\f4good\f1.
.SS In-line Editing Options
Normally, each command line entered from a terminal device is simply
typed followed by a new-line (`RETURN' or `LINE\ FEED').
If the
.\"
.\" the next four lines were commented out because AT&T does not support emacs
.\"If either the
.\"\f4emacs\f1,
.\"\f4gmacs\f1,
.\"or
\f4vi\f1
option is active, the user can edit the command line.
.\"  The next line should also be used (nstead of the one after it
.\"  if you have emacs
.\"To be in either of these edit modes \f4set\f1 the corresponding option.
To be in this edit mode \f4set\f1 the \f4vi\f1 option.
An editing option is automatically selected each time the
\f4VISUAL\f1
or
\f4EDITOR\f1
variable is assigned a value ending in either of these
option names.
.PP
The editing features require that the user's terminal
accept `RETURN' as carriage return without line feed
and that a space (`\ ') must overwrite the current character on
the screen.
ADM terminal users should set the "space - advance"
switch to `space'.
Hewlett-Packard series 2621 terminal users should set the straps to
`bcGHxZ\ etX'.
.PP
.\"  The next line should also be used (nstead of the one after it
.\"  if you have emacs
.\"The editing modes implement a concept where the user is looking through a
The editing mode implements a concept where the user is looking through a
window at the current line.
The window width is the value of
\f4COLUMNS\f1
if it is defined, otherwise 80.
If the line is longer than the window width minus two, a mark is
displayed at the end of the window to notify the user.
As the cursor moves and reaches the window boundaries the window will be
centered about the cursor.
The mark is a
\f4>\f1 (<\f4,\f1
\f4*\f1)
if the line extends on the
right (left, both) side(s) of the window.
.PP
The search commands in each edit mode provide access to the history file.
Only strings are matched, not patterns, although a leading
\f4^\f1
in the string restricts the match
to begin at the first character in the line.
.\"
.\" the next section was commented out because AT&T does not support emacs
.\"
.\".SS Emacs Editing Mode
.\"This mode is entered by enabling either the
.\".I emacs
.\"or
.\".I gmacs
.\"option.
.\"The only difference between these two modes is the way
.\"they handle
.\"\f4^T\f1.
.\"To edit, the user
.\"moves the cursor to the point needing correction and
.\"then inserts or deletes characters or words as needed.
.\"All the editing commands are control characters or escape
.\"sequences.
.\"The notation for control characters is caret (
.\"\f4^\f1
.\") followed
.\"by the character.
.\"For example,
.\"\f4^F\f1
.\"is the notation for
.\"CTRL-\f4f\fP.
.\"This is entered by depressing `f' while holding down the
.\"`CTRL' (control) key.
.\"(The notation
.\"\f4^?\f1
.\"indicates the DEL (delete) key.)
.\".PP
.\"The notation for escape sequences is
.\"\f4M-\f1
.\"followed by a
.\"character.
.\"For example,
.\"\f4M-f\f1
.\"(pronounced Meta f)
.\"is entered by depressing ESC
.\"(ascii
.\"\f4\e033\f1)
.\"followed by `f'.
.\"\f1(\f4M-F\f1
.\"would be the notation for ESC followed by `SHIFT' (capital) `F'.)
.\".PP
.\"All edit commands
.\"operate from any place on the line
.\"(not just at the beginning).
.\"Neither the "RETURN" nor the "LINE FEED" key is
.\"entered after edit commands except when noted.
.\".PP
.\".PD 0
.\".TP 10
.\"\f4^F\f1
.\"Move cursor forward (right) one character.
.\".PP
.\".TP 10
.\"\f4M-f\f1
.\"Move cursor forward one word.
.\"(The emacs editor's idea of a word is a string of characters
.\"consisting of only letters, digits and underscores.)
.\".PP
.\".TP 10
.\"\f4^B\f1
.\"Move cursor backward (left) one character.
.\".PP
.\".TP 10
.\"\f4M-b\f1
.\"Move cursor backward one word.
.\".PP
.\".TP 10
.\"\f4^A\f1
.\"Move cursor to start of line.
.\".PP
.\".TP 10
.\"\f4^E\f1
.\"Move cursor to end of line.
.\".PP
.\".TP 10
.\"\f4^]\f2char\f1
.\"Move cursor forward to character
.\".I char
.\"on current line.
.\".PP
.\".TP 10
.\"\f4M-^]\f2char\f1
.\"Move cursor back to character
.\".I char
.\"on current line.
.\".PP
.\".TP 10
.\"\f4^X^X\f1
.\"Interchange the cursor and mark.
.\".PP
.\".TP 10
.\".I erase
.\"(User defined erase character as defined
.\"by the
.\"\f4stty\fP(1)
.\"command, usually
.\"\f4^H\f1
.\"or
.\"\f4#\f1.)
.\"Delete previous character.
.\".PP
.\".TP 10
.\"\f4^D\f1
.\"Delete current character.
.\".PP
.\".TP 10
.\"\f4M-d\f1
.\"Delete current word.
.\".PP
.\".TP 10
.\"\f4M-^H\f1
.\"(Meta-backspace) Delete previous word.
.\".PP
.\".TP 10
.\"\f4M-h\f1
.\"Delete previous word.
.\".PP
.\".TP 10
.\"\f4M-^?\f1
.\"(Meta-DEL) Delete previous word (if your interrupt character is
.\"\f4^?\f1
.\"(DEL, the default) then this command will not work).
.\".PP
.\".TP 10
.\"\f4^T\f1
.\"Transpose current character with next character in
.\".I emacs
.\"mode.
.\"Transpose two previous characters in
.\".I gmacs
.\"mode.
.\".PP
.\".TP 10
.\"\f4^C\f1
.\"Capitalize current character.
.\".PP
.\".TP 10
.\"\f4M-c\f1
.\"Capitalize current word.
.\".PP
.\".TP 10
.\"\f4M-l\f1
.\"Change the current word to lower case.
.\".PP
.\".TP 10
.\"\f4^K\f1
.\"Delete from the cursor to the end of the line.
.\"If preceded by a numerical parameter whose value is less than the
.\"current cursor position, then delete from given position
.\"up to the cursor.
.\"If preceded by a numerical parameter whose value is greater than the
.\"current cursor position, then delete from cursor up to
.\"given cursor position.
.\".PP
.\".TP 10
.\"\f4^W\f1
.\"Kill from the cursor to the mark.
.\".PP
.\".TP 10
.\"\f4M-p\f1
.\"Push the region from the cursor to the mark on the stack.
.\".PP
.\".TP 10
.\"\f4kill\fP
.\"(User defined kill character as defined
.\"by the stty command, usually
.\"\f4^G\f1
.\"or
.\"\f4@\f1.)
.\"Kill the entire current line.
.\"If two
.\"\f4kill\fP
.\"characters are entered in succession, all
.\"kill characters from then on cause a line feed
.\"(useful when using paper terminals).
.\".PP
.\".TP 10
.\"\f4^Y\f1
.\"Restore last item removed from line. (Yank item back to the line.)
.\".PP
.\".TP 10
.\"\f4^L\f1
.\"Line feed and print current line.
.\".PP
.\".TP 10
.\"\f4^@\f1
.\"(Null character) Set mark.
.\".PP
.\".TP 10
.\"\f4M-\f4space\fP
.\"(Meta space) Set mark.
.\".PP
.\".TP 10
.\"\f4^J	\f1
.\"(New\ line) Execute the current line.
.\".PP
.\".TP 10
.\"\f4^M	\f1
.\"(Return) Execute the current line.
.\".PP
.\".TP 10
.\".I eof
.\"End-of-file character,
.\"normally
.\"\f4^D\f1,
.\"is processed as an End-of-file only
.\"if the current line is null.
.\".PP
.\".TP 10
.\"\f4^P\f1
.\"Fetch previous command.
.\"Each time
.\"\f4^P\f1
.\"is entered
.\"the previous command back in time is accessed.
.\"Moves back one line when not on the first line of a multi-line command.
.\".PP
.\".TP 10
.\"\f4M-<\f1
.\"Fetch the least recent (oldest) history line.
.\".PP
.\".TP 10
.\"\f4M->\f1
.\"Fetch the most recent (youngest) history line.
.\".PP
.\".TP 10
.\"\f4^N\f1
.\"Fetch next command line.
.\"Each time
.\"\f4^N\f1
.\"is entered
.\"the next command line forward in time is accessed.
.\".PP
.\".TP 10
.\"\f4^R\f2string\f1
.\"Reverse search history for a previous command line containing
.\".IR string .
.\"If a parameter of zero is given, the search is forward.
.\".I String
.\"is terminated by a "RETURN" or "NEW\ LINE".
.\"If string is preceded by a
.\"\f4^\f1,
.\"the matched line must begin with
.\".IR string .
.\"If
.\".I string
.\"is omitted,
.\"then the next command line containing the most recent
.\".I string
.\"is accessed.
.\"In this case a parameter of zero
.\"reverses the direction of the search.
.\".PP
.\".TP 10
.\"\f4^O\f1
.\"Operate \- Execute the current line and fetch
.\"the next line relative to current line from the
.\"history file.
.\".PP
.\".TP 10
.\"\f4M-\f2digits\f1
.\"(Escape) Define numeric parameter, the digits
.\"are taken as a parameter to the next command.
.\"The commands that accept a parameter are
.\"\f4^F\f1,
.\"\f4^B\f1,
.\".IR erase ,
.\"\f4^C\f1,
.\"\f4^D\f1,
.\"\f4^K\f1,
.\"\f4^R\f1,
.\"\f4^P\f1,
.\"\f4^N\f1,
.\"\f4^]\f1,
.\"\f4M-.\f1,
.\"\f4M-^]\f1,
.\"\f4M-_\f1,
.\"\f4M-b\f1,
.\"\f4M-c\f1,
.\"\f4M-d\f1,
.\"\f4M-f\f1,
.\"\f4M-h\f1
.\"\f4M-l\f1
.\"and
.\"\f4M-^H\f1.
.\".PP
.\".TP 10
.\"\f4M-\f2letter\f1
.\"Soft-key \- Your alias list is searched for an
.\"alias by the name
.\"\f4_\f2letter\f1
.\"and if an alias of this name is defined, its
.\"value will be inserted on the input queue.
.\"The
.\".I letter
.\"must not be one of the above meta-functions.
.\"\f4M-]\f2letter\f1
.\"Soft-key \- Your alias list is searched for an
.\"alias by the name
.\"\f4__\f2letter\f1
.\"and if an alias of this name is defined, its
.\"value will be inserted on the input queue.
.\"The can be used to program functions keys on many terminals.
.\".PP
.\".TP 10
.\"\f4M-.\f1
.\"The last word of the previous command is inserted
.\"on the line.
.\"If preceded by a numeric parameter, the value
.\"of this parameter determines which word to insert rather than
.\"the last word.
.\".PP
.\".TP 10
.\"\f4M-_\f1
.\"Same as
.\"\f4M-.\f1.
.\".PP
.\".TP 10
.\"\f4M-*\f1
.\"Attempt file name generation on the current word.
.\"An asterisk is appended if the word doesn't match any file
.\"or contain any special
.\"pattern characters.
.\".PP
.\".TP 10
.\"\f4M-ESC\f1
.\"File name completion.
.\"Replaces the current word with the longest common prefix of all
.\"filenames matching the current word with an asterisk appended.
.\"If the match is unique, a
.\"\f4/\f1
.\"is appended if the file is a directory and a space is
.\"appended if the file is not a directory.
.\".PP
.\".TP 10
.\"\f4M-=\f1
.\"List files matching current word pattern
.\"if an asterisk were appended.
.\".PP
.\".TP 10
.\"\f4^U\f1
.\"Multiply parameter of next command by 4.
.\".PP
.\".TP 10
.\"\f4\e\f1
.\"Escape next character.
.\"Editing characters, the user's erase, kill and
.\"interrupt (normally
.\"\f4^?\f1)
.\"characters
.\"may be entered
.\"in a command line or in a search string if preceded by a
.\"\f4\e\f1.
.\"The
.\"\f4\e\f1
.\"removes the next character's
.\"editing features (if any).
.\".PP
.\".TP 10
.\"\f4^V\f1
.\"Display version of the shell.
.\".PP
.\".TP 10
.\"\f4M-\#\f1
.\"Insert a
.\"\f4\#\f1
.\"at the beginning of the line and execute it.
.\"This causes a comment to be inserted in the history file.
.\".PD
.SS Vi Editing Mode
There are two typing modes.
Initially, when you enter a command you are in the
.I input\^
mode.
To edit, the user enters
.I control\^
mode by typing ESC (\f4\e033\fP)
and moves the cursor to the point needing correction and
then inserts or deletes characters or words as needed.
Most control commands accept an optional repeat
.I count
prior to the command.
.PP
When in \f4vi\f1 mode on most systems,
canonical processing is initially enabled and the
command will be echoed again if the speed is 1200 baud or greater and it
contains any control characters or less than one second has elapsed
since the prompt was printed.
The ESC character terminates canonical processing for the remainder of the command
and the user can then modify the command line.
This scheme has the advantages of canonical processing with the type-ahead
echoing of raw mode.
.PP
If the option
\f4viraw\^\f1
is also set, the terminal will always have canonical processing
disabled.
.SS "\ \ \ \ \ Input Edit Commands"
.PP
.RS
By default the editor is in input mode.
.PD 0
.TP 10
.I erase
(User defined erase character as defined
by the stty command, usually
\f4^H\f1
or
\f4#\f1.)
Delete previous character.
.TP 10
\f4^W\f1
Delete the previous blank separated word.
.TP 10
\f4^D\f1
Terminate the shell.
.TP 10
\f4^V\f1
Escape next character.
Editing characters, the user's erase or kill
characters may be entered
in a command line or in a search string if preceded by a
\f4^V\f1.
The
\f4^V\f1
removes the next character's
editing features (if any).
.TP 10
\f4\e\f1
Escape the next
.I erase
or
\f4kill\fP
character.
.PP
.RE
.SS "\ \ \ \ \ Motion Edit Commands"
.RS
These commands will move the cursor.
.TP 10
[\f2count\fP]\f4l\fP
Cursor forward (right) one character.
.TP 10
[\f2count\fP]\f4w\fP
Cursor forward one alpha-numeric word.
.TP 10
[\f2count\fP]\f4W\fP
Cursor to the beginning of the next word that follows a blank.
.TP 10
[\f2count\fP]\f4e\fP
Cursor to end of word.
.TP 10
[\f2count\fP]\f4E\fP
Cursor to end of the current blank delimited word.
.TP 10
[\f2count\fP]\f4h\fP
Cursor backward (left) one character.
.TP 10
[\f2count\fP]\f4b\fP
Cursor backward one word.
.TP 10
[\f2count\fP]\f4B\fP
Cursor to preceding blank separated word.
.TP 10
[\f2count\fP]\f4\(bv\fP
Cursor to column
.IR count .
.TP 10
[\f2count\fP]\f4f\fP\f2c\fP
Find the next character \f2c\fP in the current line.
.TP 10
[\f2count\fP]\f4F\fP\f2c\fP
Find the previous character \f2c\fP in the current line.
.TP 10
[\f2count\fP]\f4t\fP\f2c\fP
Equivalent to
\f4f\f1
followed by
\f4h\f1.
.TP 10
[\f2count\fP]\f4T\fP\f2c\fP
Equivalent to
\f4F\f1
followed by
\f4l\f1.
.TP 10
[\f2count\fP]\f4;\fP
Repeats
.I count
times,
the last single character find command,
\f4f\f1,
\f4F\f1,
\f4t\f1,
or
\f4T\f1.
.TP 10
[\f2count\fP]\f4,\fP
Reverses the last single character find command
.I count
times.
.TP 10
\f40\f1
Cursor to start of line.
.TP 10
\f4^\f1
Cursor to first non-blank character in line.
.TP 10
\f4$\f1
Cursor to end of line.
.RE
.SS "\ \ \ \ \ Search Edit Commands"
.RS
These commands access your command history.
.TP 10
[\f2count\fP]\f4k\fP
Fetch previous command.
Each time
\f4k\f1
is entered
the previous command back in time is accessed.
.TP 10
[\f2count\fP]\f4\-\fP
Equivalent to
\f4k\f1.
.TP 10
[\f2count\fP]\f4j\fP
Fetch next command.
Each time
\f4j\f1
is entered
the next command forward in time is accessed.
.TP 10
[\f2count\fP]\f4+\fP
Equivalent to
\f4j\f1.
.TP 10
[\f2count\fP]\f4G\fP
The command number
.I count
is fetched.
The default is the least recent history command.
.TP 10
\f4/\f2string\f1
Search backward through history for a previous command containing
.IR string .
.I String
is terminated by a "RETURN" or "NEW\ LINE".
If string is preceded by a
\f4^\f1,
the matched line must begin with
.IR string .
If \f2string\fP is null the previous string will be used.
.TP 10
\f4?\f2string\f1
Same as
\f4/\f1
except that search will be in the forward direction.
.TP 10
\f4n\f1
Search for next match of the last pattern to
\f4/\f1
or
\f4?\f1
commands.
.TP 10
\f4N\f1
Search for next match of the last pattern to
\f4/\f1
or
\f4?\f1,
but in reverse direction.
Search history for the \f2string\fP entered by the previous \f4/\fP command.
.RE
.SS "\ \ \ \ \ Text Modification Edit Commands"
.RS
These commands will modify the line.
.TP 10
\f4a\f1
Enter input mode and enter text after the current character.
.TP 10
\f4A\f1
Append text to the end of the line.
Equivalent to
\f4$a\f1.
.TP 10
[\f2count\fP]\f4c\fP\f2motion\fP
.TP 10
\f4c\fP[\f2count\fP]\f2motion\fP
Delete current character through the character that
.I motion
would move the cursor to and enter input mode.
If \f2motion\fP is
\f4c\f1,
the entire line will be deleted and
input mode entered.
.TP 10
\f4C\f1
Delete the current character through the end of line and enter input mode.
Equivalent to
\f4c$\f1.
.TP 10
\f4S\f1
Equivalent to
\f4cc\f1.
.TP 10
\f4D\f1
Delete the current character through the end of line.
Equivalent to
\f4d$\f1.
.TP 10
[\f2count\fP]\f4d\fP\f2motion\fP
.TP 10
\f4d\fP[\f2count\fP]\f2motion\fP
Delete current character through the character that
.I motion
would move to.
If \f2motion\fP is
\f4d\f1,
the entire line will be deleted.
.TP 10
\f4i\f1
Enter input mode and insert text before the current character.
.TP 10
\f4I\f1
Insert text before the beginning of the line.
Equivalent to
\f40i\f1.
.TP 10
[\f2count\fP]\f4P\fP
Place the previous text modification before the cursor.
.TP 10
[\f2count\fP]\f4p\fP
Place the previous text modification after the cursor.
.TP 10
\f4R\f1
Enter input mode and
replace characters on the screen with characters you type overlay fashion.
.TP 10
[\f2count\fP]\f4r\fP\f2c\fP
Replace the
.I count
character(s) starting at the current cursor position with
.IR c ,
and advance the cursor.
.TP 10
[\f2count\fP]\f4x\fP
Delete current character.
.TP 10
[\f2count\fP]\f4X\fP
Delete preceding character.
.TP 10
[\f2count\fP]\f4.\fP
Repeat the previous text modification command.
.TP 10
[\f2count\fP]\f4\(ap\fP
Invert the case of the
.I count
character(s) starting at the current cursor position and advance the cursor.
.TP 10
[\f2count\fP]\f4_\fP
Causes the
.I count\^
word of the previous command to be appended and
input mode entered.
The last word is used
if
.I count\^
is omitted.
.TP 10
\f4*\f1
Causes an
\f4*\f1
to be appended to the current word and file name generation attempted.
If no match is found,
it rings the bell.
Otherwise, the word is replaced
by the matching pattern and input mode is entered.
.TP 10
\f4\e \f1
Filename completion.
Replaces the current word with the longest common prefix of all
filenames matching the current word with an asterisk appended.
If the match is unique, a
\f4/\f1
is appended if the file is a directory and a space is
appended if the file is not a directory.
.RE
.SS "\ \ \ \ \ Other Edit Commands"
.RS
Miscellaneous commands.
.TP 10
[\f2count\fP]\f4y\fP\f2motion\fP
.TP 10
\f4y\fP[\f2count\fP]\f2motion\fP
Yank current character through character that
.I motion
would move the cursor to and puts them into the delete buffer.
The text and cursor are unchanged.
.TP 10
\f4Y\f1
Yanks from current position to end of line.
Equivalent to
\f4y$\f1.
.TP 10
\f4u\f1
Undo the last text modifying command.
.TP 10
\f4U\f1
Undo all the text modifying commands performed on the line.
.TP 10
[\f2count\fP]\f4v\fP
Returns the command
\f4fc \-e ${VISUAL:\-${EDITOR:\-vi}}\f2 count\f1
in the input buffer.
If
.I count\^
is omitted, then the current line is used.
.TP 10
\f4^L\f1
Line feed and print current line.
Has effect only in control mode.
.TP 10
\f4^J	\f1
(New\ line) Execute the current line, regardless of mode.
.TP 10
\f4^M	\f1
(Return) Execute the current line, regardless of mode.
.TP 10
\f4\#\f1
Sends the line after
inserting a
\f4\#\f1
in front of the line.
Useful for causing the current line to be
inserted in the history without being executed.
.TP 10
\f4=	\f1
List the file names that match the current word if an asterisk were
appended it.
.TP 10
\f4@\f2letter\f1
Your alias list is searched for an
alias by the name
\f4_\f2letter\f1
and if an alias of this name is defined, its
value will be inserted on the input queue for processing.
.RE
.PD
.SS Special Commands.
The following simple-commands are executed in the shell process.
Input/Output redirection is permitted.
Unless otherwise indicated, the output is written on file descriptor 1
and the exit status, when there is no syntax error, is zero.
Commands that are preceded by one or two \(dg
are treated specially in the following ways:
.PD 0
.TP
1.
Variable assignment lists preceding the command
remain in effect when the command completes.
.TP
2.
I/O redirections are processed after variable assignments.
.TP
3.
Errors
cause a script
that contains them to abort.
.TP
4.
Words,
following a command preceded by \(dg\(dg
that are in the format of a variable assignment,
are expanded with the same rules as a variable assignment.
This means that
tilde substitution is performed after the
\f4=\f1
sign and word splitting and file name generation are not
performed.
.PD
.TP
\(dg \f4:\fP \*(OK \f2arg\^\fP .\|.\|. \*(CK
The command only expands parameters.
.br
.ne 2
.TP
\(dg \f4\|. \f2file\^\fP \*(OK \f2arg\^\fP .\|.\|. \*(CK
Read the complete
.I file\^
then execute the commands.
The commands are executed in the current Shell environment.
The search path
specified by
\f4PATH\fP
is used to find the directory containing
.IR file .
If any arguments
.I arg\^
are given,
they become the positional parameters.
Otherwise the positional parameters are unchanged.
The exit status is the exit status of the last command executed.
.TP
\(dg\(dg \f4alias\fP \*(OK \f4\-tx\fP \*(CK  \*(OK \f2name\fP\*(OK \f4=\fP\f2value\^\fP  \*(CK \*(CK .\|.\|.
.I Alias\^
with no arguments prints the list of aliases
in the form
.I name=value\^
on standard output.
An
.I alias\^
is defined
for each name whose
.I value\^
is given.
A trailing space in
.I value\^
causes the next word to be checked for
alias substitution.
The
\f4\-t\f1
flag is used to set and list tracked aliases.
The value of a tracked alias is the full pathname
corresponding to the given
.IR name .
The value becomes undefined when the value of
\f4PATH\f1
is reset but the aliases remain tracked.
Without the
\f4\-t\f1
flag,
for each
.I name\^
in the argument list
for which no
.I value\^
is given, the name
and value of the alias is printed.
The
\f4\-x\f1
flag is used to set or print exported aliases.
An exported alias is defined for scripts invoked by name.
The exit status is non-zero if a
.I name\^
is given, but no value, for which no alias has been defined.
.TP
\f4bg\fP \*(OK \f2job\^\fP.\|.\|. \*(CK
This command is only on systems that support job control.
Puts each specified
.I job\^
into the background.
The current job is put in the background
if
.I job\^
is not specified.
See
.I Jobs
for a description of the format of
.IR job .
.TP
\(dg \f4break\fP \*(OK \f2n\^\fP \*(CK
Exit from the enclosing
\f4for\f1,
\f4while\f1,
\f4until\f1
or
\f4select\^\f1
loop, if any.
If
.I n\^
is specified then break
.I n\^
levels.
.TP
\(dg \f4continue\fP \*(OK \f2n\^\fP \*(CK
Resume the next iteration of the enclosing
\f4for\f1,
\f4while\f1,
\f4until\f1
or
\f4select\^\f1
loop.
If
.I n\^
is specified then resume at the
.IR n -th
enclosing loop.
.TP
.PD 0
\f4cd\fP \*(OK \f2arg\^\fP \*(CK
.TP
\f4cd\fP \f2old\^\fP \f2new\^\fP
.PD
This command can be in either of two forms.
In the first form it
changes the current directory to
.IR arg .
If
.I arg\^
is
\f4\-\f1
the directory is changed to the previous directory.
The shell variable \f4HOME\fP is the default
.IR arg .
The variable \f4PWD\f1
is set to the current directory.
The shell variable
\f4CDPATH\fP
defines the search path for
the directory containing
.IR arg .
Alternative directory names are separated by
a colon
\f1(\f4:\f1).
The default path is
\f4<null>\f1
(specifying the current directory).
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
.I arg
begins with a \f4/\fP then the search path
is not used.
Otherwise, each directory in the path is
searched for
.IR arg .
.PP
The second form of
\f4cd\f1
substitutes the string
.I new
for the string
.I old
in the current directory name,
\f4PWD\f1
and tries to change to this new directory.
.PP
The
\f4cd\^\f1
command may not be executed by
.I rksh\^.
.TP
\f4echo\fP \*(OK \f2arg\^\fP .\|.\|. \*(CK
See
\f4echo\fP(1)
for usage and description.
.TP
\(dg \f4eval\fP \*(OK \f2arg\^\fP .\|.\|. \*(CK
The arguments are read as input
to the shell
and the resulting command(s) executed.
.TP
\(dg \f4exec\fP \*(OK \f2arg\^\fP .\|.\|. \*(CK
If
.I arg\^
is given,
the command specified by
the arguments is executed in place of this shell
without creating a new process.
Input/output arguments may appear and
affect the current process.
If no
arguments are given
the effect of this command is to
modify file descriptors
as prescribed by the input/output redirection list.
In this case,
any file descriptor numbers greater than 2 that are
opened with this mechanism are closed when invoking
another program.
.TP
\(dg \f4exit\fP \*(OK \f2n\^\fP \*(CK
Causes the shell to exit
with the exit status specified by
.IR n .
If
.I n\^
is omitted then the exit status is that of the last command executed.
An end-of-file will also cause the shell to exit
except for a
shell which has the
.I ignoreeof
option (see
\f4set\f1
below) turned on.
.TP
\(dg\(dg \f4export\fP \*(OK \f2name\fP\*(OK\f4=\fP\f2value\^\fP\*(CK \*(CK .\|.\|.
The given
.IR name s
are marked for automatic
export to the
.I environment\^
of subsequently-executed commands.
.TP
.PD 0
\f4fc\fP \*(OK \f4\-e\fP \f2ename\^\fP \ \*(CK \*(OK \f4\-nlr\^\fP \*(CK \*(OK \f2first\^\fP \*(OK \f2last\^\fP \*(CK \*(CK
.TP
\f4fc \-e \-\fP \*(OK \f2old\fP\f4\=\fP\f2new\^\fP \*(CK \*(OK \f2command\^\fP \*(CK
.PD
In the first form,
a range of commands from
.I first\^
to
.I last\^
is selected from the last
\f4HISTSIZE\f1
commands that were typed at the terminal.
The arguments
.I first\^
and
.I last\^
may be specified as a number or as a string.
A string is used to locate the most recent command starting with
the given string.
A negative number is used as an offset to the current command number.
If the flag
\f4\-l\f1,
is selected,
the commands are listed on standard output.
Otherwise, the editor program
.I ename\^
is invoked on a file containing these
keyboard commands.
If
.I ename\^
is not supplied, then the value of the variable
\f4FCEDIT\f1
(default /usr/bin/ed)
is used as the editor.
When editing is complete, the edited command(s)
is executed.
If
.I last\^
is not specified
then it will be set to
.IR first .
If
.I first\^
is not specified
the default is the previous command
for editing and \-16 for listing.
The flag
\f4\-r\f1
reverses the order of the commands and
the flag
\f4\-n\f1
suppresses command numbers when listing.
In the second form the
.I command\^
is re-executed after the substitution
\f2old\^\fP\f4=\fP\f2new\^\fP
is performed.
.TP
\f4fg\fP \*(OK \f2job\^\fP.\|.\|. \*(CK
This command is only on systems that support job control.
Each
.I job\^
specified is brought to the foreground.
Otherwise, the current job is
brought into the foreground.
See
.I Jobs
for a description of the format of
.IR job .
.TP
\f4getopts\fP \f2optstring name\^\fP \*(OK \f2arg\^\fP .\|.\|. \*(CK
Checks
.I arg
for legal options.
If
.I arg
is omitted,
the positional parameters are used.
An option argument begins with a
\f4+\f1
or a
\f4\-\f1.
An option not beginning with
\f4+\f1
or 
\f4\-\f1
or the argument
\f4\-\|\-\f1
ends the options.
.I optstring
contains the letters that
\f4getopts\fP
recognizes.
If a letter is followed by a
\f4:\f1,
that option is expected to have an argument.
The options can be separated from the argument by blanks.
.IP
\f4getopts\fP
places the next option letter it finds inside variable
.IR name
each time it is invoked with a
\f4+\f1
prepended when
.I arg
begins with a
\f4+\f1.
The index of the next
.I arg
is stored in
\f4OPTIND\f1.
The option argument,
if any,
gets stored in
\f4OPTARG\f1.
.IP
A leading
\f4:\f1
in
.I optstring
causes
\f4getopts\f1
to store the letter of an invalid
option in
\f4OPTARG\f1,
and to set
.I name
to
\f4?\f1
for an unknown option and to
\f4:\f1
when a required option is missing.
Otherwise,
\f4getopts\f1
prints an error message.
The exit status is non-zero when there are no more options.
.TP
\f4jobs\fP \*(OK \f4\-lnp\^\fP \*(CK \*(OK \f2job\^\fP \.\|.\|. \*(CK
Lists information about each given job; or all active jobs if
.I job
is omitted.
The
\f4\-l\f1
flag lists process ids in addition to the normal information.
The
\f4\-n\f1
flag only displays jobs that have stopped or exited since last
notified.
The
\f4\-p\f1
flag causes only the process group to be listed.
See
.I Jobs
for a description of the format of
.IR job .
.TP
.PD 0
\f4kill\fP \*(OK \f4\-\fP\f2sig\^\fP \*(CK \f2job\^\fP .\|.\|.
.TP
\f4kill\fP \f4\-l\fP
.PD
Sends either the TERM (terminate) signal or the
specified signal to the specified jobs or processes.
Signals are either given by number or by names (as given in
\f4/usr/include/signal.h\f1,
stripped of the prefix ``SIG'').
If the signal being sent is TERM (terminate) or HUP (hangup),
then the job or process will be sent a CONT (continue) signal
if it is stopped.
The argument
.I job\^
can the process id of a process that is not a member of one of the
active jobs.
See
.I Jobs
for a description of the format of
.IR job .
In the second form,
\f4kill \-l\f1,
the signal numbers and names are listed.
.TP
\f4let\fP \f2arg\^\fP .\|.\|.
Each
.I arg
is a separate
.IR "arithmetic expression"
to be evaluated.
See
.I "Arithmetic Evaluation"
above, for a description of arithmetic expression evaluation.
.IP
The exit status is
0 if the value of the last expression
is non-zero, and 1 otherwise.
.TP
\(dg \f4newgrp\fP \*(OK \f2arg\^\fP .\|.\|. \*(CK
Equivalent to
\f4exec /usr/bin/newgrp\f2 arg\^\f1
\&.\|.\|.\^.
.TP
\f4print\fP \*(OK \f4\-Rnprsu\^\fP\*(OK\f2n\fP \*(CK \*(CK \*(OK \f2arg\^\fP .\|.\|. \*(CK
The shell output mechanism.
With no flags or with flag
\f4\-\f1
or
\f4\-\|\-\f1
the arguments are printed
on standard output as described by
\f4echo\fP(1).
In raw mode,
\f4\-R\f1
or
\f4\-r\f1,
the escape conventions of
\f4echo\fP
are ignored.
The
\f4\-R\f1
option will print all subsequent arguments and options
other than
\f4\-n\f1.
The
\f4\-p\f1
option causes the
arguments to be written onto the pipe
of the process spawned with
\f4\(bv&\f1
instead of standard output.
The
\f4\-s\f1
option causes the
arguments to be written onto the history file
instead of standard output.
The
\f4\-u\f1
flag can be used to specify a one digit
file descriptor unit number
\f4n\^\f1
on which the
output will be placed.
The default is 1.
If the flag
\f4\-n\f1
is used, no
\f4new-line\^\f1
is added to the output.
.TP
\f4pwd\fP
Equivalent to
\f4print \-r \- $PWD\fP
.TP
\f4read\fP \*(OK \f4\-prsu\^\fP\*(OK \f2n\^\fP \*(CK \*(CK \*(OK \f2name\f4?\f2prompt\^\f1 \*(CK \*(OK \f2name\^\fP .\|.\|. \*(CK
The shell input mechanism.
One line is read and
is broken up into fields using the characters in
\f4IFS\fP
as separators.
In raw mode,
\f4\-r,\f1
a
\f4\e\f1
at the end of a line does not signify
line continuation.
The first
field is assigned to the first
.IR name ,
the second field
to the second
.IR name ,
etc., with leftover fields assigned to the last
.IR name .
The
\f4\-p\f1
option causes the input line
to be taken from the input pipe
of a process spawned by the shell
using
\f4\(bv&\f1.
If the
\f4\-s\f1
flag is present,
the input will be saved as a command in the history file.
The flag
\f4\-u\f1
can be used to specify a one digit file
descriptor unit to read from.
The file descriptor can be opened with the
\f4exec\^\f1
special command.
The default value of
.I n\^
is 0.
If
.IR name
is omitted then
\f4REPLY\f1
is used as the default
.IR name.
The exit status is 0 unless an end-of-file is encountered.
An end-of-file with the
\f4\-p\f1
option causes cleanup for this process
so that another can be spawned.
If the first argument contains a
\f4?\f1,
the remainder of this word is used as a
.I prompt\^
on standard error
when the shell is interactive.
The exit status is 0 unless an end-of-file is encountered.
.TP
\(dg\(dg \f4readonly\fP \*(OK \f2name\fP\*(OK\f4=\fP\f2value\^\fP\*(CK \*(CK .\|.\|.
The given
.IR names
are marked
readonly and these
names cannot be changed
by subsequent assignment.
.TP
\(dg \f4return\fP \*(OK \f2n\^\fP \*(CK
Causes a shell
.I function
to return
to the invoking script
with the return status specified by
.IR n .
If
.I n\^
is omitted then the return status is that of the last command executed.
If
\f4return\f1
is invoked while not in a
.I function
or a
\f4\|.\fP
script,
then it is the same as an
\f4exit\f1.
.TP
\f4set\fP \*(OK \f4\(+-aefhkmnpstuvx\fP \*(CK \*(OK \f4\(+-o\fP \f2option\^\fP \*(CK.\|.\|. \*(OK \f4\(+-A\fP \f2name\^\fP \*(CK  \*(OK \f2arg\^\fP .\|.\|. \*(CK
The flags for this command have meaning as follows:
.RS
.PD 0
.TP
\f4\-A\f1
Array assignment.
Unset the variable
.I name
and assign values sequentially from the
list
.IR arg .
If
\f4+A\f1
is used, the variable
.I name
is not unset first.
.TP
\f4\-a\f1
All subsequent variables that are defined are automatically exported.
.TP
\f4\-e\f1
If a command has a non-zero exit status,
execute the
\f4ERR\f1
trap, if set,
and exit.
This mode is disabled while reading profiles.
.TP
\f4\-f\f1
Disables file name generation.
.TP
\f4\-h\f1
Each command
becomes a tracked alias when first encountered.
.TP
\f4\-k\f1
All variable assignment arguments are placed in the environment for a command,
not just those that precede the command name.
.TP
\f4\-m\f1
Background jobs will run in a separate process group
and a line will print upon completion.
The exit status of background jobs is reported in a completion message.
On systems with job control,
this flag is turned on automatically for
interactive shells.
.TP
\f4\-n\f1
Read commands and check them for syntax errors, but do not execute them.
Ignored for interactive shells.
.TP
\f4\-o\f1
The following argument can be one of the following option names:
.RS
.TP 13
\f4allexport\f1
Same as
\f4\-a\f1.
.TP 13
\f4errexit\f1
Same as
\f4\-e\f1.
.TP 13
\f4bgnice\f1
All background jobs are run at a lower priority.
This is the default mode.
.\".TP 13
.\"\f4emacs\f1
.\"Puts you in an
.\".I emacs
.\"style in-line editor for command entry.
.\".TP 13
.\"\f4gmacs\f1
.\"Puts you in a
.\".I gmacs
.\"style in-line editor for command entry.
.TP 13
\f4ignoreeof\f1
The shell will not exit on end-of-file.
The command
\f4exit\f1
must be used.
.TP 13
\f4keyword\f1
Same as
\f4\-k\f1.
.TP 13
\f4markdirs\f1
All directory names resulting from file name generation have a trailing
\f4/\f1
appended.
.TP 13
\f4monitor\f1
Same as
\f4\-m\f1.
.TP 13
\f4noclobber\f1
Prevents redirection
\f4>\f1
from truncating existing files.
Require
\f4>\(bv\f1
to truncate a file when turned on.
.TP 13
\f4noexec\f1
Same as
\f4\-n\f1.
.TP 13
\f4noglob\f1
Same as
\f4\-f\f1.
.TP 13
\f4nolog\f1
Do not save function definitions in history file.
.TP 13
\f4nounset\f1
Same as
\f4\-u\f1.
.TP 13
\f4privileged\f1
Same as
\f4\-p\f1.
.TP 13
\f4verbose\f1
Same as
\f4\-v\f1.
.TP 13
\f4trackall\f1
Same as
\f4\-h\f1.
.TP 13
\f4vi\f1
Puts you in insert mode of a
\f4vi\fP
style in-line editor
until you hit escape character
\f4033\f1.
This puts you in move mode.
A return sends the line.
.TP 13
\f4viraw\f1
Each character is processed as it is typed in \f4vi\fP mode.
.TP 13
\f4xtrace\f1
Same as \f4\-x\f1.
.P
If no option name is supplied then the current option settings are printed.
.RE
.TP
\f4\-p\f1
Disables processing of the
\f4$HOME/.profile\f1
file and uses the file
\f4/etc/suid_profile\f1
instead of the
\f4ENV\f1
file.
This mode is on whenever the effective uid (gid)
is not equal to the real uid (gid).
Turning this off causes the effective uid and gid to be
set to the real uid and gid.
.TP
\f4\-s\f1
Sort the positional parameters lexicographically.
.TP
\f4\-t\f1
Exit after reading and executing one command.
.TP
\f4\-u\f1
Treat unset parameters as an error when substituting.
.TP
\f4\-v\f1
Print shell input lines as they are read.
.TP
\f4\-x\f1
Print commands and their arguments as they are executed.
.TP
\f4\-\f1
Turns off
\f4\-x\f1
and
\f4\-v\f1
flags and stops examining arguments for flags.
.TP
\f4\-\|\-\f1
Do not change any of the flags; useful in setting
\f4$1\f1
to a value beginning with
\f4\-\f1.
If no arguments follow this flag then the positional parameters are unset.
.PD
.PP
Using
\f4\+\f1
rather than
\f4\-\f1
causes these flags to be turned off.
These flags can also be used upon invocation of the shell.
The current set of flags may be found in
\f4$\-\f1.
Unless
\f4\-A\f1
is specified,
the remaining arguments are positional
parameters and are assigned, in order, to
\f4$1\f1
\f4$2\f1
\&.\|.\|.\^.
If no arguments are given then the names and values
of all variables are printed on the standard output.
.RE
.TP
\(dg \f4shift\fP \*(OK \f2n\^\fP \*(CK
.br
The positional parameters from
\f4$\fP\f2n\fP\f4+1\fP
\&.\|.\|.
are renamed
\f4$1\f1
\&.\|.\|.\^
, default
.I n\^
is 1.
The parameter
.I n\^
can be any arithmetic expression that evaluates to a non-negative
number less than or equal to
\f4$#\f1.
.TP
\(dg \f4times\fP
.br
Print the accumulated user and system times for
the shell and for processes
run from the shell.
.TP
\(dg \f4trap\fP \*(OK \f2arg\^\fP \*(CK \*(OK \f2sig\^\fP \*(CK .\|.\|.
.I arg\^
is a command to be read and executed when the shell
receives signal(s)
.IR sig .
(Note that
.I arg\^
is scanned once when
the trap is set and once when the trap
is taken.)
Each
.I sig\^
can be given as a number or as the name of the signal.
Trap commands are executed in order of signal number.
Any attempt to set a trap on a signal that
was ignored on entry to the current shell
is ineffective.
If
.I arg\^
is omitted or is
\f4\-\f1,
then all trap(s)
.I sig\^
are reset
to their original values.
If
.I arg\^
is the null
string then this signal is ignored by the shell and by the commands
it invokes.
If
.I sig\^
is
\f4ERR\f1
then
.I arg\^
will be executed whenever a command has a non-zero exit status.
.I sig\^
is
\f4DEBUG\f1
then
.I arg\^
will be executed after each command.
If
.I sig\^
is
\f40\f1
or
\f4EXIT\f1
and the
\f4trap\f1
statement is executed inside the body of a function,
then the command
.I arg\^
is executed
after the function completes.
If
.I sig\^
is
\f40\f1
or
\f4EXIT\f1
for a
\f4trap\f1
set outside any function
then the command
.I arg\^
is executed
on exit from the shell.
The
\f4trap\f1
command
with no arguments prints a list
of commands associated with each signal number.
.TP
\(dg\(dg \f4typeset\fP \*(OK \f4\(+-HLRZfilrtux\^\fP\*(OK\f2n\fP\*(CK \*(CK  \*(OK \f2name\fP\*(OK \f4=\fP\f2value\^\fP \*(CK \^ \*(CK .\|.\|.
Sets attributes and values for shell variables.
When invoked inside a function,
a new instance of the variable
.I name\^
is created.
The parameter value and type are restored
when the function completes.
The following list of attributes may be specified:
.PD 0
.RS
.TP
\f4\-H\f1
This flag provides UNIX to host-name file mapping on non-UNIX
machines.
.TP
\f4\-L\f1
Left justify and remove leading blanks from
.IR value .
If
.I n
is non-zero it defines the width
of the field,
otherwise it is determined by the width of the value of
first assignment.
When the variable is assigned to, it is
filled on the right with blanks or truncated, if necessary, to
fit into the field.
Leading zeros are removed if the
\f4\-Z\f1
flag is also set.
The
\f4\-R\f1
flag is turned off.
.TP
\f4\-R\f1
Right justify and fill with leading blanks.
If
.I n
is non-zero it defines the width
of the field,
otherwise it is determined by the width of the value of
first assignment.
The field is left filled with blanks or
truncated from the end if the
variable is reassigned.
The
\f4L\f1
flag is turned off.
.TP
\f4\-Z\f1
Right justify and fill with leading zeros if
the first non-blank character is a digit and the
\f4\-L\f1
flag has not been set.
If
.I n
is non-zero it defines the width
of the field,
otherwise it is determined by the width of the value of
first assignment.
.TP
\f4\-f\f1
The names refer to function names rather than
variable names.
No assignments can be made and the only other
valid flags are
\f4\-t\f1,
\f4\-u\f1
and
\f4\-x\f1.
The flag
\f4\-t\f1
turns on execution tracing for this function.
The flag
\f4\-u\f1
causes this function to be marked undefined.
The
\f4FPATH\f1
variable will be searched to find the function definition
when the function is referenced.
The flag
\f4\-x\f1
allows the function definition to remain in effect across shell
procedures invoked by name.
.TP
\f4\-i\f1
Variable is an integer.
This makes arithmetic faster.
If
.I n
is non-zero it defines the output arithmetic base,
otherwise the first assignment determines the output base.
.TP
\f4\-l\f1
All upper-case characters
converted to lower-case.
The upper-case flag,
\f4\-u\f1
is turned off.
.TP
\f4\-r\f1
The given
.IR names
are marked
readonly and these
names cannot be changed
by subsequent assignment.
.TP
\f4\-t\f1
Tags the variables.
Tags are user definable and have no special
meaning to the shell.
.TP
\f4\-u\f1
All lower-case characters are converted
to upper-case characters.
The lower-case flag,
\f4\-l\f1
is turned off.
.TP
\f4\-x\f1
The given
.IR name s
are marked for automatic
export to the
.I environment\^
of subsequently-executed commands.
.PD
.PP
Using
\f4\+\f1
rather than
\f4\-\f1
causes these flags to be turned off.
If no
.I name\^
arguments are given but flags are specified,
a list of
.I names\^
(and optionally the
\f4values\fP)
of the
.I variables\^
which have these
flags set
is printed.
(Using
\f4\+\f1
rather than
\f4\-\f1
keeps the
values from being printed.)
If no
.IR name s
and flags
are given,
the
.I names\^
and
.I attributes\^
of all
.I variables\^
are printed.
.RE
.TP
\f4ulimit\fP \*(OK \-\*(OK\f4HS\fP\*(CK\*(OK\f4a\fP \(bv \f4cdfnstv\fP\*(CK \*(CK 
.TP
\f4ulimit\fP \*(OK \-\*(OK\f4HS\fP\*(CK\*(OK\f4c\fP \(bv \f4d\fP \(bv \f4f\fP \(bv \f4n\fP \(bv \f4s\fP \(bv \f4t\fP \(bv \f4v\fP\*(CK \*(CK \f2limit\f1
\f4ulimit\f1
prints or sets hard or soft resource limits.
These limits are described in
\f4getrlimit\fP(2).
.IP "" 
If
.I limit
is not present,
\f4ulimit\f1
prints the specified limits.
Any number of limits may be printed at one time.
The \f4\-a\f1 option prints all limits.
.IP "" 
If
.I limit
is present, \f4ulimit\f1 sets the specified limit to
.IR limit .
The string \f4unlimited\f1 requests the largest valid limit.
Limits may be set for only one resource at a time.
Any user may set a soft limit to any value below the hard limit.
Any user may lower a hard limit.
Only
the super-user
may raise a hard limit; see \f4su\fP(1).
.IP ""
The \f4\-H\f1 option specifies a hard limit.
The \f4\-S\f1 option specifies a soft limit.
If neither option is specified, \f4ulimit\f1 will set both limits and print the
soft limit.
.IP ""
The following options specify the resource whose limits are to be printed or set.
If no option is specified, the file size limit is printed or set.
.RS
.TP
\f4\-c\f1
maximum core file size (in 512-byte blocks)
.TP
\f4\-d\f1
maximum size of data segment or heap (in kbytes)
.TP
\f4\-f\f1
maximum file size (in 512-byte blocks)
.TP
\f4\-n\f1
maximum file descriptor plus 1
.TP
\f4\-s\f1
maximum size of stack segment (in kbytes)
.TP
\f4\-t\f1
maximum CPU time (in seconds)
.TP
\f4\-v\f1
maximum size of virtual memory (in kbytes)
.PP
If no option is given,
\f4\-f\f1
is assumed.
.RE
.TP
\f4umask\fP \*(OK \f2mask\^\fP \*(CK
The user file-creation mask is set to
.I mask\^
[see
\f4umask\fP(2)].
.I mask
can either be an octal number or
a symbolic value as described in
\f4chmod\fP(1). 
If a symbolic value is given,
the new
umask value is the complement of the result of
applying
.I mask\^
to the complement of the previous umask value.
If
.I mask\^
is omitted, the current value of the mask is printed.
.TP
\f4unalias\fP \f2name\^\fP .\|.\|.
The
.IR
variables
given by the list of
.IR name s
are removed from the
.I alias\^
list.
.TP
\f4unset\fP \*(OK \f4\-f\fP \*(CK \f2name\^\fP .\|.\|.
The variables given by the list of
.IR name s
are unassigned,
i. e.,
their values and attributes are erased.
Read-only variables cannot be unset.
If the flag,
\f4\-f\f1,
is set, then the names refer to
.I function\^
names.
Unsetting
\f4ERRNO\f1,
\f4LINENO\f1,
\f4MAILCHECK\f1,
\f4OPTARG\f1,
\f4OPTIND\f1,
\f4RANDOM\f1,
\f4SECONDS\f1,
\f4TMOUT\f1,
and
\f4_\f1
causes removes their special meaning even if they are
subsequently assigned to.
.TP
\(dg \f4wait\fP \*(OK \f2job\^\fP \*(CK
Wait for the specified
.I job
and
report its termination status.
If
.I job\^
is not given then all currently active child processes are waited for.
The exit status from this command is that of
the process waited for.
See
.I Jobs
for a description of the format of
.IR job .
.TP
\f4whence\fP \*(OK \f4\-pv\fP \*(CK \f2name\^\fP .\|.\|.
For each
.IR name ,
indicate how it
would be interpreted if used as a command name.
.RS
.TP
\f4\-v\f1
produces a more verbose report.
.TP
\f4\-p\f1
does a path search for
.I name\^
even if name is an alias, a function, or a reserved word.
.RE
.SS Invocation.
If the shell is invoked by
\f4exec\fP(2),
and the first character of argument zero
\f1(\f4$0\f1)
is
\f4\-\f1,
then the shell is assumed to be a
\f4login\fP
shell and
commands are read from
\f4/etc/profile\f1
and then from either \f4.profile\f1
in the current directory or
\f4$HOME/.profile\f1,
if either file exists.
Next, commands are read from
the file named by
performing parameter substitution on
the value of the environment variable
\f4ENV\f1
if the file exists.
If the
\f4\-s\f1
flag is not present and
.I arg\^
is, then a path search is performed on the first
.I arg\^
to determine the name of the script to execute.
The script
.I arg\^
must have read permission and any
\f4setuid\fP
and
\f4setgid\fP
settings will be ignored.
Commands are then read as described below;
the following flags are interpreted by the shell
when it is invoked:
.PP
.PD 0
.TP 10
\f4\-c\f2\| string\^\f1
If the
\f4\-c\f1
flag is present then
commands are read from
.IR string .
.TP
\f4\-s\f1
If the
\f4\-s\f1
flag is present or if no
arguments remain
then commands are read from the standard input.
Shell output,
except for the output of the
.I Special commands\^
listed above,
is written to
file descriptor 2.
.TP
\f4\-i\f1
If the
\f4\-i\f1
flag is present or
if the shell input and output are attached to a terminal (as told by
\f4ioctl\fP(2))
then this shell is
.IR interactive .
In this case
.SM TERM
is ignored (so that \f4kill 0\fP
does not kill an interactive shell) and
.SM INTR
is caught and ignored
(so that
\f4wait\f1
is interruptible).
In all cases,
.SM QUIT
is ignored by the shell.
.TP
\f4\-r\f1
If the
\f4\-r\f1
flag is present the shell is a restricted shell.
.PD
.PP
The remaining flags and arguments are described under the
\f4set\f1
command above.
.SS Rksh Only.
.I Rksh\}
is used to set up login names and execution environments whose
capabilities are more controlled than those of the standard shell.
The actions of
.I rksh\^
are identical to those of
\f4sh\fP,
except that the following are disallowed:
.RS
.PD 0
.PP
changing directory [see
\f4cd\fP(1)],
.br
setting the value of
\f4SHELL\f1,
\f4ENV\f1,
or
\f4PATH\*S,\f1
.br
specifying path or
command names containing
\f4/\f1,
.br
redirecting output
\f1(\f4>\f1,
\f4>| ,\f1
\f4<> ,\f1
and
\f4>>\f1).
.PD
.RE
.PP
The restrictions above are enforced
after \f4.profile\fP and the
\f4ENV\f1
files are interpreted.
.PP
When a command to be executed is found to be a shell procedure,
.I rksh\^
invokes
.I ksh\^\}
to execute it.
Thus, it is possible to provide to the end-user shell procedures
that have access to the full power of
the standard shell,
while imposing a limited menu of commands;
this scheme assumes that the end-user does not have write and
execute permissions in the same directory.
.PP
The net effect of these rules is that the writer of the \f4.profile\f1
has complete control over user actions,
by performing guaranteed setup actions
and leaving the user in an appropriate directory
(probably
.I not\^
the login directory).
.PP
The system administrator often sets up a directory
of commands
(i.e.,
\f4/usr/rbin\f1)
that can be safely invoked by
.IR rksh .
.SH EXIT STATUS
Errors detected by the shell, such as syntax errors,
cause the shell
to return a non-zero exit status.
Otherwise, the shell returns the exit status of
the last command executed (see also the
\f4exit\f1
command above).
If the shell is being used non-interactively
then execution of the shell file is abandoned.
Run time errors detected by the shell are reported by
printing the command or function name and the error condition.
If the line number that the error occurred on is greater than one,
then the line number is also printed in square brackets
\f1(\f4[]\f1)
after the command or function name.
.SH FILES
/etc/passwd
.br
/etc/profile
.br
/etc/suid_profile
.br
$HOME/\f4.\fPprofile
.br
/tmp/sh\(**
.br
/dev/null
.SH SEE ALSO
\f4cat\fP(1),
\f4cd\fP(1),
\f4chmod\fP(1),
\f4cut\fP(1),
\f4echo\fP(1),
.\"\f4emacs\fP(1),
\f4env\fP(1),
.\"\f4gmacs\fP(1),
\f4paste\fP(1),
\f4stty\fP(1),
\f4test\fP(1),
\f4umask\fP(1), and
\f4vi\fP(1).
.br
\f4dup\fP(2),
\f4exec\fP(2),
\f4fork\fP(2),
\f4ioctl\fP(2),
\f4lseek\fP(2),
\f4pipe\fP(2),
\f4signal\fP(2),
\f4umask\fP(2),
\f4ulimit\fP(2),
\f4wait\fP(2), and
\f4rand\fP(3C)
in the \f2Programmer's Reference Manual\f1.
.br
\f4newgrp\fP(1M),
\f4a.out\fP(4),
\f4profile\fP(4), and
\f4environ\fP(4)
in the \f2System Administrator's Reference Manual\f1.
.PP
Morris I. Bolsky and David G. Korn,
.IR "The KornShell Command and Programming Language" ,
Prentice Hall, 1989.
.SH NOTES
.PP
If a command which is a
.I "tracked alias"
is executed, and then a command with the same name is
installed in a directory in the search path before the directory where the
original command was found, the shell will continue to
\f4exec\fP
the original command.
Use the
\f4\-t\f1
option of the
\f4alias\^\f1
command to correct this situation.
.PP
Some very old shell scripts contain a
\f4^\f1
as a synonym for the pipe character.
\f4\(bv\f1.
.PP
Using the
\f4fc\^\f1
built-in command within a compound command will cause the whole
command to disappear from the history file.
.PP
The built-in command \f4\|.\fP \f2file\^\fP
reads the whole file before any commands are executed.
Therefore,
\f4alias\f1
and
\f4unalias\f1
commands in the file
will not apply to any functions defined in the file.
.PP
Traps are not processed while a job is waiting for a foreground process.
Thus, a trap on
\f4CHLD\f1
won't be executed until the foreground job terminates.
