4.3 The Set Builtin
This builtin is so complicated that it deserves its own section.
set [--abefhkmnptuvxBCHP] [-o option]
If no options or arguments are supplied,
set displays the names
and values of all shell variables and functions, sorted according to the
current locale, in a format that may be reused as input.
When options are supplied, they set or unset shell attributes.
Options, if specified, have the following meanings:
Using '+' rather than '-' causes these options to be
turned off. The options can also be used upon invocation of the
shell. The current set of options may be found in
Mark variables and function which are modified or created for export
to the environment of subsequent commands.
Cause the status of terminated background jobs to be reported
immediately, rather than before printing the next primary prompt.
Exit immediately if a simple command (see section 3.2.1 Simple Commands) exits
with a non-zero status, unless the command that fails is part of an
while loop, part of an
part of a
|| list, or if the command's return
status is being inverted using
A trap on
ERR, if set, is executed before the shell exits.
Disable file name generation (globbing).
Locate and remember (hash) commands as they are looked up for execution.
This option is enabled by default.
All arguments in the form of assignment statements are placed
in the environment for a command, not just those that precede
the command name.
Job control is enabled (see section 7 Job Control).
Read commands but do not execute them; this may be used to check a
script for syntax errors.
This option is ignored by interactive shells.
Set the option corresponding to option-name:
emacs-style line editing interface (see section 8 Command Line Editing).
Enable command history, as described in section 9.1 Bash History Facilities.
This option is on by default in interactive shells.
An interactive shell will not exit upon reading EOF.
Change the behavior of Bash where the default operation differs
from the POSIX 1003.2 standard to match the standard
(see section 6.11 Bash POSIX Mode).
This is intended to make Bash behave as a strict superset of that
vi-style line editing interface.
Turn on privileged mode.
In this mode, the
$ENV files are not
processed, shell functions are not inherited from the environment,
SHELLOPTS variable, if it appears in the environment,
If the shell is started with the effective user (group) id not equal to the
real user (group) id, and the
-p option is not supplied, these actions
are taken and the effective user id is set to the real user id.
-p option is supplied at startup, the effective user id is
Turning this option off causes the effective user
and group ids to be set to the real user and group ids.
Exit after reading and executing one command.
Treat unset variables as an error when performing parameter expansion.
An error message will be written to the standard error, and a non-interactive
shell will exit.
Print shell input lines as they are read.
Print a trace of simple commands and their arguments after they are
expanded and before they are executed.
The shell will perform brace expansion (see section 3.5.1 Brace Expansion).
This option is on by default.
Prevent output redirection using '>', '>&', and '<>'
from overwriting existing files.
Enable '!' style history substitution (see section 9.3 History Expansion).
This option is on by default for interactive shells.
If set, do not follow symbolic links when performing commands such as
cd which change the current directory. The physical directory
is used instead. By default, Bash follows
the logical chain of directories when performing commands
which change the current directory.
For example, if '/usr/sys' is a symbolic link to '/usr/local/sys'
$ cd /usr/sys; echo $PWD
$ cd ..; pwd
set -P is on, then:
$ cd /usr/sys; echo $PWD
$ cd ..; pwd
If no arguments follow this option, then the positional parameters are
unset. Otherwise, the positional parameters are set to the
arguments, even if some of them begin with a '-'.
Signal the end of options, cause all remaining arguments
to be assigned to the positional parameters. The
-v options are turned off.
If there are no arguments, the positional parameters remain unchanged.
The remaining N arguments are positional parameters and are
assigned, in order, to
The special parameter
# is set to N.
The return status is always zero unless an invalid option is supplied.