Name

set — Manage shell options and the script’s command-line parameters.

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 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. The exact behavior is complicated; see set -e Details, later in this entry.

-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 the entry for hash.

-H

Enable csh-style history substitution. On by default. See the section C-Shell–Style History.

-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. Interactive ...

Get bash Pocket 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.