This section combines Table A-5, set Options, and shopt options and provides a quick way to look for what you can configure and which of the three mechanisms you use to configure it. The options are loosely grouped according to function or purpose, but it’s worthwhile to scan the entire table to get an overall sense of what you can configure.
The “Set option” column contains the options that can be turned on
with the set
-arg
command. All are initially off except
where noted. Items in the “Set full name” column, where listed, are
arguments to set that can be used with set -o
. The full names braceexpand, histexpand, history, keyword
, and
onecmd
are not available in versions of
bash prior to 2.0. Also, in those versions, hashing
is switched with -d
.
The “Shopt option” column shows the options set with shopt -s
arg
and
unset with shopt -u
arg
. Versions of bash
prior to 2.0 had environment variables to perform some of these settings.
Setting them equated to shopt -s
. The
variables (and corresponding shopt options) were:
allow_null_glob_expansion (nullglob), cdable_vars
(cdable_vars), command_oriented_history (cmdhist), glob_dot_filenames
(dotglob), no_exit_on_failed_exec (execfail)
. These variables no
longer exist.
The options extdebug, failglob,
force_fignore
, and gnu_errfmt
are not available in versions of bash prior to
3.0.
The “Environment variable” column lists environment variables that affect bash configuration and operation. The letters in the Type column of the table have the following meanings: A = Array, L = colon-separated list, R = read-only, U = unsetting it causes it to lose its special meaning.
Note that the variables beginning BASH_
and beginning COMP
, as well as the variables DIRSTACK, FUNCNAME, GLOBIGNORE, GROUPS, HISTIGNORE,
HOSTNAME, HISTTIMEFORMAT, LANG, LC_ALL, LC_COLLATE, LC_MESSAGE, MACHTYPE,
PIPESTATUS, SHELLOPTS
, and TIMEFORMAT
are not available in versions prior
to 2.0. BASH_ENV
replaces ENV
found in earlier versions.
Table A-8. Adjusting shell behavior using set, shopt, and environment variables
Set option | Set full name | Shopt option | Environment variable | Env. var. type | Description |
---|---|---|---|---|---|
| An index into | ||||
| The current command line. This variable is available only in shell functions and external commands invoked by the programmable completion facilities. | ||||
| The index of the current cursor position relative to
the beginning of the current command. If the current cursor
position is at the end of the current command, the value of this
variable is equal to | ||||
| U | The set of characters that the Readline library
treats as word separators when performing word completion. If
| |||
| A | An array of the individual words in the current command line. This variable is available only in shell functions invoked by the programmable completion facilities. | |||
| A | The possible completions generated by a shell function invoked by the programmable completion facility. | |||
| L | A list of names to ignore when doing filename completion. | |||
| The suffixes specified by the | ||||
| If readline is being used, an attempt will be made to perform hostname completion when a word beginning with @ is being completed. | ||||
| The file to be used for hostname completion. | ||||
| If readline is being used, no
attempt will be made to search the | ||||
| Programmable completion facilities are enabled. Default is on. | ||||
| The readline startup file. | ||||
| | Don’t allow redirection to overwrite existing files. | |||
| | Exit after reading and executing one command. | |||
| | Do not follow symbolic links on commands that change the current directory. Use the physical directory. | |||
| Set if the shell is started in restricted mode. The value cannot be changed. | ||||
| LR | A list of enabled shell options. | |||
| The source built-in uses the value of | ||||
| A | An array of values, which are the number of
parameters in each frame of the current bash execution call stack.
The number of parameters to the current subroutine (shell function
or script executed with . or | |||
| A | All of the parameters in the current bash execution call stack. The final parameter of the last subroutine call is at the top of the stack; the first parameter of the initial call is at the bottom. | |||
| The command currently being executed or about to be executed, unless the shell is executing a command as the result of a trap, in which case it is the command executing at the time of the trap. | ||||
| A | An array whose members are the line numbers in source
files corresponding to each member of | |||
| A | An array containing the source filenames
corresponding to the elements in the | |||
| | Any trap on | |||
| Behavior intended for use by debuggers is enabled.
This includes: the | ||||
| ARU | An array containing the names of all shell functions currently in the execution call stack. The element with index 0 is the name of any currently-executing shell function. The bottom-most element is “main.” This variable exists only when a shell function is executing. | |||
| | Any trap on | |||
| U | The number of the line that just ran in a script or function. | |||
| | Read commands and check syntax but do not execute them. Ignored for interactive shells. | |||
| | Print shell input lines before running them. | |||
| | Print commands (after expansions) before running them. | |||
| Incremented by 1 each time a subshell or subshell environment is spawned. The initial value is 0. A subshell is a forked copy of the parent shell and shares it’s environment. | ||||
| Incremented by 1 each time a new instance (not a subshell) of bash is invoked. This is intended to be a count of how deeply your bash shells are nested. | ||||
| | Export all subsequently defined or modified variables. | |||
| The name of a file to run as the environment file when the shell is invoked. | ||||
| The command argument to the | ||||
| AR | Version information for this instance of bash. Each element of the array holds parts of the version number. | |||
| The version number of this instance of bash. | ||||
- | R | Options given to the shell on invocation. | |||
- | Signals the end of options. All remaining arguments
are assigned to the positional parameters. | ||||
| Shell error messages are written in the standard GNU error message format. | ||||
| The home (login) directory. | ||||
| The name of the current host. | ||||
| The type of machine bash is running on. | ||||
| bash will send | ||||
-- | With no arguments following, unset the positional parameters. Otherwise, the positional parameters are set to the following arguments (even if they begin with -). | ||||
| The Internal Field Separator: a list of characters that act as word separators. Normally set to space, tab, and newline. | ||||
| | Place keyword arguments in the environment for a command. | |||
| Used to determine the locale category for any
category not specifically selected with a variable starting with
| ||||
| Overrides the value of | ||||
| Determines the collation order used when sorting the results of pathname expansion. | ||||
| Determines the interpretation of characters and the behavior of character classes within pathname expansion and pattern matching. | ||||
| This variable determines the locale used to translate double-quoted strings preceded by a $. | ||||
| Determines the locale category used for number formatting. | ||||
| If bash is started as a login shell. This is a read-only value. | ||||
| A string describing the system on which bash is executing. | ||||
| L | The search path for commands. | |||
| U | The number of seconds since the shell was invoked. | |||
| | The shell performs brace expansion. This is on by default. | |||
| Filenames beginning with a . are included in pathname expansion. | ||||
| Aliases are expanded. | ||||
| Extended pattern matching features are enabled. | ||||
| Patterns that fail to match filenames during pathname expansion result in an expansion error. | ||||
| L | A list of patterns defining filenames to ignore during pathname expansion. | |||
| bash matches filenames in a caseinsensitive fashion when performing pathname expansion. | ||||
| | Disable pathname expansion. | |||
| Cause patterns that match no files to expand to null strings rather than to themselves. | ||||
| Commands found in the hash table are checked for
existence before being executed, and nonexistence forces a
| ||||
| | Disable the hashing of commands. | |||
| Attempt to save all lines of a multiline command in a single history entry. | ||||
| The history list is appended to the file named by the
value of the variable | ||||
| Specifies what to use as the history control characters. Normally set to the string !^#. | ||||
| U | The history number of the current command. | |||
| A list of patterns, separated by colons (:), which
can have the following values. | ||||
| | Enable ! style history substitution. On by default in an interactive shell. | |||
| The name of the command history file. | ||||
| The maximum number of lines kept in the history file. | ||||
| A list of patterns to decide what should be retained in the history list. | ||||
| Enable command history. On by default in interactive shells. | ||||
| If readline is being used, the opportunity is given for re-editing a failed history substitution. | ||||
| The number of lines kept in the command history. | ||||
| If set and not null, its value is used as a format string for strftime(3) to print the timestamp associated with each history entry displayed by the history built-in. If this variable is set, timestamps are written to the history file so they may be preserved across shell sessions. | ||||
| If readline is being used, the results of history substitution are not immediately passed to the shell parser. Instead, the resulting line is loaded into the readline editing buffer, allowing further modification. | ||||
| If the | ||||
| The number of EOF characters received before exiting an interactive shell. | ||||
| Disallow Ctrl-D to exit the shell. | ||||
| An argument to cd that is not a directory is assumed to be the name of a variable whose value is the directory to change to. | ||||
| L | A list of directories for the cd command to search. | |||
| Minor errors in the spelling of a directory supplied to the cd command will be corrected if there is a suitable match. This correction includes missing letters, incorrect letters, and letter transposition. It works for interactive shells only. | ||||
| Checks the window size after each command and, if it
has changed, updates the variables | ||||
| ARU | The current contents of the directory stack. | |||
| Use Emacs-style command-line editing. | ||||
| The default editor for the fc command. | ||||
| Allows a word beginning with # and all subsequent characters on the line to be ignored in an interactive shell. | ||||
| The previous working directory. | ||||
| The value is executed as a command before the primary prompt is issued. | ||||
| Prompt strings undergo variable and parameter expansion after being expanded. | ||||
| The primary command prompt string. | ||||
| The prompt string for line continuations. | ||||
| The prompt string for the select command. | ||||
| The prompt string for the | ||||
| The current working directory. | ||||
| The shift built-in prints an error if it has shifted past the last positional parameter. | ||||
| Specifies the format for the output from using the time reserved word on a command pipeline. | ||||
| If set to a positive integer, the number of seconds after which the shell automatically terminates if no input is received. | ||||
- | R | Last argument to the previous command. | |||
| Use vi-style command-line editing. | ||||
| Controls how job control works (values are exact, substring, or something other than those keywords). | ||||
| | Enable job control (on by default in interactive shells). | |||
| | Report the status of terminating background jobs immediately. | |||
| The name of the file to check for new mail. | ||||
| How often (in seconds) to check for new mail. | ||||
| L | A list of file names to check for new mail, if
| |||
| If the file being checked for mail has been accessed since the last time it was checked, the message “The mail in mailfile has been read” is displayed. | ||||
| The return value of a pipeline is the value of the last (rightmost) command to exit with a nonzero status, or zero if all commands in the pipeline exit successfully. This option is disabled by default. | ||||
| A | An array variable containing a list of exit status values from the processes in the most recently executed foreground pipeline. | |||
| Change the default behavior to that of POSIX 1003.2 where it differs from the standard. | ||||
| If in the environment when bash
starts, the shell enters posix mode before reading the startup
files, as if the | ||||
| echo expands backslash-escape sequences by default. | ||||
| AR | An array whose members are assigned by the =~ binary operator to the [[ conditional command. The element with index 0 is the portion of the string matching the entire regular expression. The element with index n is the portion of the string matching the nth parenthesized subexpression. | |||
| R | Name of the shell or shell script. | |||
* | R | A single string containing the positional parameters
given to the current script or function, separated by the first
character of | |||
@ | R | Each of the positional parameters given to the
current script or function, given as a list of double-quoted
strings (e.g., | |||
| The full pathname used to invoke this instance of bash. | ||||
$ | R | Process ID of the shell process. | |||
| | Exit the shell when a simple command exits with
nonzero status. A simple command is a command not part of a
| |||
| R | The effective user ID of the current user. | |||
! | R | Process ID of the last background command. | |||
| A noninteractive shell will not exit if it cannot execute the argument to an exec. Interactive shells do not exit if exec fails. | ||||
| AR | An array containing a list of groups of which the current user is a member. | |||
| | Treat undefined variables as errors, not as null. | |||
| The value of the last option argument processed by
| ||||
| If set to 1, display error messages from | ||||
| The number of the first argument after options. | ||||
| The operating system on which bash is executing. | ||||
# | R | The number of arguments given to the current script or function. | |||
| R | The process ID of the parent process. | |||
| | Script is running in suid mode. | |||
? | R | Exit status of the previous command. | |||
| U | A random number between 0 and | |||
| The user’s response to the | ||||
| The full pathname of the shell. | ||||
| R | The user ID of the current user. |
3.17.184.90