Name

set

Synopsis

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. (See the earlier section Invoking the Shell.) Arguments are assigned in order to $1, $2, etc.

Options

-a

From now on, automatically mark variables for export after defining or changing them.

-b

Print job completion messages as soon as jobs terminate; don't wait until the next prompt.

-B

Enable brace expansion. On by default.

-C

Prevent overwriting via > redirection; use >| to overwrite files.

-e

Exit if a command yields a nonzero exit status. The ERR trap executes before the shell exits.

-E

Cause shell functions, command substitutions, and subshells to inherit the ERR trap.

-f

Ignore filename metacharacters (e.g., * ? [ ]).

-h

Locate commands as they are defined. On by default. See hash.

-H

Enable csh-style history substitution. On by default.

-k

Assignment of environment variables (var=value) takes effect regardless of where they appear on the command line. Normally, assignments must precede the command name.

-m

Enable job control; background jobs execute in a separate process group. -m is usually set automatically.

-n

Read commands but don't execute; useful for checking syntax. The shell ignores this option if interactive.

+o [mode]

With mode, disable the given shell option. Plain set +o prints the settings of all the current options. This is in a form that can be reread by ...

Get bash Quick Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.