set - set/unset options and positional parameters


set [ options ] [arg ...]


set sets or unsets options and positional parameters. Options that are specified with a - cause the options to be set. Options that are specified with a + cause the option to be unset.

set without any options or arguments displays the names and values of all shell variables in the order of the collation sequence in the current locale. The values are quoted so that they are suitable for reinput to the shell.

If no args are specified, not even the end of options argument --, the positional parameters are unchanged. Otherwise, unless the -A options has been specified, the positional parameters are replaced by the list of args. A first arg of -- is ignored when setting positional parameters.

For backward compatibility, a set command without any options specified whose first arg is - will turn off the -v and -x options. If any additional args are specified, they will replace the positional parameters.


Sort the positional parameters.
-A name
Assign the arguments sequentially to the array named by name starting at subscript 0 rather than to the positional parameters.
Set the export attribute for each variable whose name does not contain a . that you assign a value in the current shell environment.
The shell writes a message to standard error as soon it detects that a background job completes rather than waiting until the next prompt.
A simple command that has an non-zero exit status will cause the shell to exit unless the simple command is:
contained in an && or || list.
the command immediately following if, while, or until.
contained in the pipeline following !.
Pathname expansion is disabled.
Obsolete. Causes each command whose name has the syntax of an alias to become a tracked alias when it is first encountered.
This is obsolete. All arguments of the form name=value are removed and placed in the variable assignment list for the command. Ordinarily, variable assignments must precede command arguments.
When enabled, the shell runs background jobs in a separate process group and displays a line upon completion. This mode is enabled by default for interactive shells on systems that support job control.
The shell reads commands and checks for syntax errors, but does not execute the command. Usually specified on command invocation.
If option is not specified, the list of options and their current settings will be written to standard output. When invoked with a + the options will be written in a format that can be reinput to the shell to restore the settings. This option can be repeated to enable/disable multiple options. The value of option must be one of the following:
Equivalent to -a.
Runs background jobs at lower priorities.
Equivalent to -B.
Enables/disables emacs editing mode.
Equivalent to -e.
Equivalent to -G.
Enables/disables gmacs editing mode. gmacs editing mode is the same as emacs editing mode except for the handling of ^T.
Equivalent to -H.
Prevents an interactive shell from exiting on reading an end-of-file.
Equivalent to -k.
A trailing / is appended to directories resulting from pathname expansion.
Equivalent to -m.
Use multiple lines when editing lines that are longer than the window width.
Equivalent to -C.
Equivalent to -n.
Equivalent to -f.
This has no effect. It is provided for backward compatibility.
Equivalent to -b.
Equivalent to -u.
A pipeline will not complete until all components of the pipeline have completed, and the exit status of the pipeline will be the value of the last command to exit with non-zero exit status, or will be zero if all commands return zero exit status.
Equivalent to -p.
Simple commands preceded by a ; will be traced as if -x were enabled but not executed.
Equivalent to -h.
Equivalent to -v.
Enables/disables vi editing mode.
Does not use canonical input mode when using vi edit mode.
Equivalent to -x.
The option value may be omitted.
Privileged mode. Disabling -p sets the effective user id to the real user id, and the effective group id to the real group id. Enabling -p restores the effective user and group ids to their values when the shell was invoked. The -p option is on whenever the real and effective user id is not equal or the real and effective group id is not equal. User profiles are not processed when -p is enabled.
restricted. Enables restricted shell. This option cannot be unset once enabled.
Obsolete. The shell reads one command and then exits.
If enabled, the shell displays an error message when it tries to expand a variable that is unset.
Verbose. The shell displays its input onto standard error as it reads it.
Execution trace. The shell will display each command after all expansion and before execution preceded by the expanded value of the PS4 parameter.
Enable {...} group expansion. On by default.
Prevents existing regular files from being overwritten using the > redirection operator. The >| redirection overrides this noclobber option.
Causes ** by itself to also match all sub-directories during pathname expansion.
Enable !-style history expansion similar to csh.
Restore all non-command line options to the default settings.
List the current option state in the form of a set command that can be executed to restore the state.


No errors occurred.
An error occurred.


typeset(1), shift(1)


set (AT&T Research) 1999-09-28
David Korn <>
Copyright © 1982-2010 AT&T Intellectual Property