POSIX Shell

All POSIX compatible shells support a standard set of options that can be set to customize the shell's behavior. Some options correspond to simple user preferences, such as which editor bindings (vi or emacs) to use. Other options, such as verbose and xtrace, are important for debugging scripts.

Shell options are viewed and set using the builtin set command. When using the set command the option will be preceded with a -(minus) to set the option on or, the logical opposite, a +(plus) symbol to set the option off.

The shell also maintains a list of the options currently set in the $-variable in the form of single letter indicators. The following examples show the results fo activating a few common shell options. Complete documentation is found i the Bash manual page and help set prints an excellent summary with description of options.

Shell Options Example: noclobber

rex@bunturx:~$ echo $- himBH

POSIX Shell Compatible Options

BASH SHELL OPTIONS

Bash Shell Options

Useful for customizing shell and debugging scripts

Standard sh compatible options

    • view: set -o or echo $-

    • set: set [-opt] [-o opt_name]

    • unset: set set [+opt] [+o opt_name]

Entended Bash Options

    • view: shopt

    • set: shopt -s opt_name

    • unset: shopt -u opt_name