Go to the previous, next section.

The Set Builtin

This builtin is so overloaded that it deserves its own section.

set
set [-abefhkmnptuvxldCHP] [-o option] [argument ...]

-a
Mark variables which are modified or created for export.

-b
Cause the status of terminated background jobs to be reported immediately, rather than before printing the next primary prompt.

-e
Exit immediately if a command exits with a non-zero status.

-f
Disable file name generation (globbing).

-h
Locate and remember (hash) commands as functions are defined, rather than when the function is executed.

-k
All keyword arguments are placed in the environment for a command, not just those that precede the command name.

-m
Job control is enabled (see section Job Control).

-n
Read commands but do not execute them.

-o option-name

Set the flag corresponding to option-name:

allexport
same as -a.

braceexpand
the shell will perform brace expansion (see section Brace Expansion).

emacs
use an emacs-style line editing interface (see section Command Line Editing).

errexit
same as -e.

histexpand
same as -H.

ignoreeof
the shell will not exit upon reading EOF.

interactive-comments
allow a word beginning with a `#' to cause that word and all remaining characters on that line to be ignored in an interactive shell.

monitor
same as -m.

noclobber
same as -C.

noexec
same as -n.

noglob
same as -f.

nohash
same as -d.

notify
same as -b.

nounset
same as -u.

physical
same as -P.

posix
change the behavior of Bash where the default operation differs from the Posix 1003.2 standard to match the standard. This is intended to make Bash behave as a strict superset of that standard.

privileged
same as -p.

verbose
same as -v.

vi
use a vi-style line editing interface.

xtrace
same as -x.

  • -p Turn on privileged mode. In this mode, the $ENV file is not processed, and shell functions are not inherited from the environment. This is enabled automatically on startup if the effective user (group) id is not equal to the real user (group) id. Turning this option off causes the effective user and group ids to be set to the real user and group ids.

  • -t Exit after reading and executing one command.

  • -u Treat unset variables as an error when substituting.

  • -v Print shell input lines as they are read.

  • -x Print commands and their arguments as they are executed.

  • -l Save and restore the binding of the name in a for command.

  • -d Disable the hashing of commands that are looked up for execution. Normally, commands are remembered in a hash table, and once found, do not have to be looked up again.

  • -C Disallow output redirection to existing files.

  • -H Enable ! style history substitution. This flag is on by default.

  • -P If set, do not follow symbolic links when performing commands such as cd which change the current directory. The physical directory is used instead.

  • -- If no arguments follow this flag, 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 -x and -v options are turned off. If there are no arguments, the positional parameters remain unchanged.
  • Using `+' rather than `-' causes these flags to be turned off. The flags can also be used upon invocation of the shell. The current set of flags may be found in $-. The remaining N arguments are positional parameters and are assigned, in order, to $1, $2, .. $N. If no arguments are given, all shell variables are printed.

    Go to the previous, next section.