set [options arg1 arg2 ...]With no arguments, set prints the values of all variables known to the current shell. Options can be enabled (-option) or disabled (+option). Options can also be set when the shell is invoked, via ksh or sh. (See the earlier section "Invoking the Shell.") Arguments are assigned in order to $1, $2, etc.
+A nameAssign remaining arguments as elements of array name. Korn shell only.
-A nameSame as +A, but unset name before making assignments. Korn shell only.
-aFrom now on automatically mark variables for export after defining or changing them.
-bSame as -o notify. The single-letter form is only in ksh93.
-CSame as -o noclobber. The single-letter form is only in ksh93.
-eExit if a command yields a nonzero exit status. In the Korn shell, the ERR trap is executed before the shell exits.
-fIgnore filename metacharacters (e.g., * ? [ ]).
-hLocate commands as they are defined. The Korn shell creates tracked aliases, whereas the Bourne shell hashes command names. See hash.
-kAssignment of environment variables (var=value) takes effect regardless of where they appear on the command line. Normally, assignments must precede the command name.
-mEnable job control; background jobs execute in a separate process group. -m is usually set automatically. Korn shell only.
-nRead commands but don't execute; useful for checking syntax. The Korn shell ignores this option if it is interactive.
-o [mode]List Korn shell modes, or turn on mode mode. Many modes can be set by other options. Modes are:
allexport | Same as |
bgnice | Run background jobs at lower priority. |
emacs | Set command-line editor to |
errexit | Same as |
ignoreeof | Don't process EOF signals. To exit the shell, type |
keyword | Same as |
markdirs | Append / to directory names. |
monitor | Same as |
noclobber | Prevent overwriting via |
noexec | Same as |
noglob | Same as |
nolog | Omit function definitions from history file. |
notify | Print job completion messages as soon as jobs terminate; don't wait until the next prompt. |
nounset | Same as |
privileged | Same as |
trackall | Same as |
verbose | Same as |
vi | Set command-line editor to |
viraw | Same as |
xtrace | Same as |
-pStart up as a privileged user (i.e., don't process $HOME/.profile).
-sSort the positional parameters. Korn shell only.
-tExit after one command is executed.
-uIn substitutions, treat unset variables as errors.
-vShow each shell command line when read.
-xShow commands and arguments when executed, preceded by a +. (Korn shell: precede with the value of PS4.) This provides step-by-step debugging of shell scripts.
-Turn off -v and -x, and turn off option processing. Included in Korn shell for compatibility with older versions of Bourne shell.
--Used as the last option; -- turns off option processing so that arguments beginning with - are not misinterpreted as options. (For example, you can set $1 to -1.) If no arguments are given after --, unset the positional parameters.
set - "$num" -20 -30 Set $1 to $num, $2 to -20, $3 to -30 set -vx Read each command line; show it; execute it; show it again (with arguments) set +x Stop command tracing set -o noclobber Prevent file overwriting set +o noclobber Allow file overwriting again