.TH set "" "" Command
.PC "Set shell option flags and positional parameters"
\fBset [\-ceiknstuvx [\fIname ...\^\fB] ]\fR (Bourne shell)
\fBset [[+\-]aefhkmnuvx] [[+\-]o \fIname\^\fB]\fR (Korn shell)
.PP
.HS
.SH Options:
.IC \fB\-a\fR
Automatically export all new variables (\fBksh\fR)
.IC "\fB\-c\fI string\fR"
Read commands from \fIstring\fR (\fBsh\fR)
.IC \fB\-e\fR
Exit on any error
.IC \fB\-f\fR
Noglob:  Don't expand file names (\fBksh\fR)
.IC \fB\-h\fR
Automatically add all commands to hash table (\fBksh\fR)
.IC \fB\-i\fR
Shell is always interactive (\fBsh\fR)
.IC \fB\-k\fR
Place all keyword arguments into environment (\fBsh\fR)
.IC \fB\-k\fR
Recognize variables anywhere in command (\fBksh\fR)
.IC \fB\-m\fR
Enable job control (\fBksh\fR)
.IC \fB\-n\fR
Read commands but do not execute
.IC "\fB\-o\fI option\fR"
Set \fIoption\fR (\fBksh\fR)
.IC \fB\-s\fR
Read commands from stdin; write to stderr (\fBsh\fR)
.IC \fB\-t\fR
Read one command rather than entire file (\fBsh\fR)
.IC \fB\-u\fR
If variable is blank, report error
.IC \fB\-v\fR
Print each line as it is read
.IC \fB\-x\fR
Print each command as it's executed
.IC \fB\-\fR
Cancel \fB\-v\fR and \fB\-x\fR options (\fBsh\fR)
.Pp
With \fBksh\fR, prefixing an option with `+' turns it on; prefixing it
with `\-' turns it off.
.HE
.B set
changes the options of the current shell
and optionally sets the values of positional parameters.
This command is used implemented by both the Bourne and Korn shells;
however, its syntax and options vary from one shell to the other.
.SH "Bourne Shell"
The shell variable `$-' contains the currently set shell flags.
If the optional
.I name
list is given,
.B set
assigns the positional parameters
\fB$1\fR, \fB$2\fR ... to the given shell variables.
.PP
.B set
recognizes the following options:
.IP "\fB\-c \fIstring\fR" 0.3i
Read shell commands from
.I string.
.IP \fB\-e\fR
Exit on any error
(command not found or command returning nonzero status)
if the shell is not interactive.
.IP \fB\-i\fR
The shell is interactive, even if the terminal is not attached to it;
print prompt strings.
For a shell reading a script,
ignore
signals
.B SIGTERM
and
.B SIGINT.
.IP \fB\-k\fR
Place all keyword arguments into the environment.
Normally, the shell places only assignments to variables preceding
the command into the environment.
.IP \fB\-n\fR
Read commands but do not execute them.
.IP \fB\-s\fR
Read commands from the standard input
and write shell output to the standard error.
.IP \fB\-t\fR
Read and execute one command rather than the entire file.
.IP \fB\-u\fR
If the actual value of a shell variable is blank, report an error
rather than
substituting the null string.
.IP \fB\-v\fR
Print each line as it is read.
.IP \fB\-x\fR
Print each command and its arguments as it is executed.
.IP \fB\-\fR
Cancel the
.B \-x
.B \-v
options.
.RE
.PP
The shell executes
.B set
directly.
.SH "Korn Shell"
.B set
recognizes the following options.
Preceding an option with `-' turns on the option; preceding it with `+'
turns it off.
.IP \fB\-a\fR 0.3i
\fBallexport\fR:
Automatically export all new variables.
.IP \fB\-e\fR
\fBerrexit\fR:
Exit from the shell when non-zero status is received.
.IP \fB\-f\fR
\fBnoglob\fR:
Do not expand file names.
This globally turns off the special meaning of characters `*' and `?'.
.IP \fB\-h\fR
\fBtrackall\fR:
Automatically
add all commands to the shell's hash table.
.IP \fB\-k\fR
\fBkeyword\fR:
Recognize variable assignments anywhere in a command.
.IP \fB\-m\fR
\fBmonitor\fR:
Enable job control.
See the Lexicon article on \fBksh\fR for details on job control and
how to use it.
.IP \fB\-n\fR
\fBnoexec\fR:
Compile an input command, but do not execute it.
.IP "\fB\-o \fIoption\fR"
Set
.I option.
.B set
recognizes the following
.IR option s:
.RS
.IP \fBallexport\fR 0.75i
Same as \fB\-a\fR option, above.
.IS \fBemacs\fR
Turn on \*(ME-style editing of command lines.
.IS \fBerrexit\fR
Same as \fB\-e\fR option, above.
.IS \fBignoreeof\fR
Tell the shell not to exit when reading EOF:
must use \fBexit\fR command to exit from the shell.
.IS \fBkeyword\fR
Same as \fB\-k\fR option, above.
.IS \fBmonitor\fR
Same as \fB\-m\fR option, above.
.IS \fBnoexec\fR
Same as \fB\-n\fR option, above.
.IS \fBnoglob\fR
Same as \fB\-f\fR option, above.
.IS \fBtrackall\fR
Same as \fB\-h\fR option, above.
.IS \fBnounset\fR
Same as \fB\-u\fR option, below.
.IS \fBverbose\fR
Same as \fB\-v\fR option, below.
.IS \fBxtrace\fR
Same as \fB\-x\fR option, below.
.RE
.IP \fB\-u\fR
\fBnounset\fR:
Treat dollar-sign expansion of an unset variable as an error.
.IP \fB\-v\fR
\fBverbose\fR:
When compiling a command, echo its compiled (i.e., expanded) version
on the standard output before executing it.
.IP \fB\-x\fR
\fBxtrace\fR:
Echo simple commands while executing.
.PP
The shells execute
.B set
directly.
.SH "See Also"
.Xr "commands," commands
.Xr "ksh," ksh
.Xr "sh," sh
.Xr "unset" unset
