bash: The Shopt Builtin
1
1 4.3.2 The Shopt Builtin
1 -----------------------
1
1 This builtin allows you to change additional shell optional behavior.
1
1 'shopt'
1 shopt [-pqsu] [-o] [OPTNAME ...]
1
1 Toggle the values of settings controlling optional shell behavior.
1 The settings can be either those listed below, or, if the '-o'
1 option is used, those available with the '-o' option to the 'set'
1 builtin command (⇒The Set Builtin). With no options, or
1 with the '-p' option, a list of all settable options is displayed,
1 with an indication of whether or not each is set. The '-p' option
1 causes output to be displayed in a form that may be reused as
1 input. Other options have the following meanings:
1
1 '-s'
1 Enable (set) each OPTNAME.
1
1 '-u'
1 Disable (unset) each OPTNAME.
1
1 '-q'
1 Suppresses normal output; the return status indicates whether
1 the OPTNAME is set or unset. If multiple OPTNAME arguments
1 are given with '-q', the return status is zero if all OPTNAMES
1 are enabled; non-zero otherwise.
1
1 '-o'
1 Restricts the values of OPTNAME to be those defined for the
1 '-o' option to the 'set' builtin (⇒The Set Builtin).
1
1 If either '-s' or '-u' is used with no OPTNAME arguments, 'shopt'
1 shows only those options which are set or unset, respectively.
1
1 Unless otherwise noted, the 'shopt' options are disabled (off) by
1 default.
1
1 The return status when listing options is zero if all OPTNAMES are
1 enabled, non-zero otherwise. When setting or unsetting options,
1 the return status is zero unless an OPTNAME is not a valid shell
1 option.
1
1 The list of 'shopt' options is:
1
1 'autocd'
1 If set, a command name that is the name of a directory is
1 executed as if it were the argument to the 'cd' command. This
1 option is only used by interactive shells.
1
1 'cdable_vars'
1 If this is set, an argument to the 'cd' builtin command that
1 is not a directory is assumed to be the name of a variable
1 whose value is the directory to change to.
1
1 'cdspell'
1 If set, minor errors in the spelling of a directory component
1 in a 'cd' command will be corrected. The errors checked for
1 are transposed characters, a missing character, and a
1 character too many. If a correction is found, the corrected
1 path is printed, and the command proceeds. This option is
1 only used by interactive shells.
1
1 'checkhash'
1 If this is set, Bash checks that a command found in the hash
1 table exists before trying to execute it. If a hashed command
1 no longer exists, a normal path search is performed.
1
1 'checkjobs'
1 If set, Bash lists the status of any stopped and running jobs
1 before exiting an interactive shell. If any jobs are running,
1 this causes the exit to be deferred until a second exit is
11 attempted without an intervening command (⇒Job
Control). The shell always postpones exiting if any jobs
1 are stopped.
1
1 'checkwinsize'
1 If set, Bash checks the window size after each command and, if
1 necessary, updates the values of 'LINES' and 'COLUMNS'.
1
1 'cmdhist'
1 If set, Bash attempts to save all lines of a multiple-line
1 command in the same history entry. This allows easy
1 re-editing of multi-line commands.
1
1 'compat31'
1 If set, Bash changes its behavior to that of version 3.1 with
1 respect to quoted arguments to the conditional command's '=~'
1 operator and with respect to locale-specific string comparison
1 when using the '[[' conditional command's '<' and '>'
1 operators. Bash versions prior to bash-4.1 use ASCII
1 collation and strcmp(3); bash-4.1 and later use the current
1 locale's collation sequence and strcoll(3).
1
1 'compat32'
1 If set, Bash changes its behavior to that of version 3.2 with
1 respect to locale-specific string comparison when using the
1 '[[' conditional command's '<' and '>' operators (see previous
1 item) and the effect of interrupting a command list. Bash
1 versions 3.2 and earlier continue with the next command in the
1 list after one terminates due to an interrupt.
1
1 'compat40'
1 If set, Bash changes its behavior to that of version 4.0 with
1 respect to locale-specific string comparison when using the
1 '[[' conditional command's '<' and '>' operators (see
1 description of 'compat31') and the effect of interrupting a
1 command list. Bash versions 4.0 and later interrupt the list
1 as if the shell received the interrupt; previous versions
1 continue with the next command in the list.
1
1 'compat41'
1 If set, Bash, when in POSIX mode, treats a single quote in a
1 double-quoted parameter expansion as a special character. The
1 single quotes must match (an even number) and the characters
1 between the single quotes are considered quoted. This is the
1 behavior of POSIX mode through version 4.1. The default Bash
1 behavior remains as in previous versions.
1
1 'compat42'
1 If set, Bash does not process the replacement string in the
1 pattern substitution word expansion using quote removal.
1
1 'compat43'
1 If set, Bash does not print a warning message if an attempt is
1 made to use a quoted compound array assignment as an argument
1 to 'declare', makes word expansion errors non-fatal errors
1 that cause the current command to fail (the default behavior
1 is to make them fatal errors that cause the shell to exit),
1 and does not reset the loop state when a shell function is
1 executed (this allows 'break' or 'continue' in a shell
1 function to affect loops in the caller's context).
1
1 'complete_fullquote'
1 If set, Bash quotes all shell metacharacters in filenames and
1 directory names when performing completion. If not set, Bash
1 removes metacharacters such as the dollar sign from the set of
1 characters that will be quoted in completed filenames when
1 these metacharacters appear in shell variable references in
1 words to be completed. This means that dollar signs in
1 variable names that expand to directories will not be quoted;
1 however, any dollar signs appearing in filenames will not be
1 quoted, either. This is active only when bash is using
1 backslashes to quote completed filenames. This variable is
1 set by default, which is the default Bash behavior in versions
1 through 4.2.
1
1 'direxpand'
1 If set, Bash replaces directory names with the results of word
1 expansion when performing filename completion. This changes
1 the contents of the readline editing buffer. If not set, Bash
1 attempts to preserve what the user typed.
1
1 'dirspell'
1 If set, Bash attempts spelling correction on directory names
1 during word completion if the directory name initially
1 supplied does not exist.
1
1 'dotglob'
1 If set, Bash includes filenames beginning with a '.' in the
1 results of filename expansion.
1
1 'execfail'
1 If this is set, a non-interactive shell will not exit if it
1 cannot execute the file specified as an argument to the 'exec'
1 builtin command. An interactive shell does not exit if 'exec'
1 fails.
1
1 'expand_aliases'
1 If set, aliases are expanded as described below under Aliases,
1 ⇒Aliases. This option is enabled by default for
1 interactive shells.
1
1 'extdebug'
1 If set at shell invocation, arrange to execute the debugger
1 profile before the shell starts, identical to the '--debugger'
1 option. If set after invocation, behavior intended for use by
1 debuggers is enabled:
1
1 Builtins::) displays the source file name and line number
1 corresponding to each function name supplied as an
1 argument.
1
1 2. If the command run by the 'DEBUG' trap returns a non-zero
1 value, the next command is skipped and not executed.
1
1 3. If the command run by the 'DEBUG' trap returns a value of
1 2, and the shell is executing in a subroutine (a shell
1 function or a shell script executed by the '.' or
1 'source' builtins), the shell simulates a call to
1 'return'.
1
1 4. 'BASH_ARGC' and 'BASH_ARGV' are updated as described in
1 their descriptions (⇒Bash Variables).
1
1 5. Function tracing is enabled: command substitution, shell
1 functions, and subshells invoked with '( COMMAND )'
1 inherit the 'DEBUG' and 'RETURN' traps.
1
1 6. Error tracing is enabled: command substitution, shell
1 functions, and subshells invoked with '( COMMAND )'
1 inherit the 'ERR' trap.
1
1 'extglob'
1 If set, the extended pattern matching features described above
1 (⇒Pattern Matching) are enabled.
1
1 'extquote'
1 If set, '$'STRING'' and '$"STRING"' quoting is performed
1 within '${PARAMETER}' expansions enclosed in double quotes.
1 This option is enabled by default.
1
1 'failglob'
1 If set, patterns which fail to match filenames during filename
1 expansion result in an expansion error.
1
1 'force_fignore'
1 If set, the suffixes specified by the 'FIGNORE' shell variable
1 cause words to be ignored when performing word completion even
11 if the ignored words are the only possible completions. ⇒
Bash Variables, for a description of 'FIGNORE'. This option
1 is enabled by default.
1
1 'globasciiranges'
1 If set, range expressions used in pattern matching bracket
1 expressions (⇒Pattern Matching) behave as if in the
1 traditional C locale when performing comparisons. That is,
1 the current locale's collating sequence is not taken into
1 account, so 'b' will not collate between 'A' and 'B', and
1 upper-case and lower-case ASCII characters will collate
1 together.
1
1 'globstar'
1 If set, the pattern '**' used in a filename expansion context
1 will match all files and zero or more directories and
1 subdirectories. If the pattern is followed by a '/', only
1 directories and subdirectories match.
1
1 'gnu_errfmt'
1 If set, shell error messages are written in the standard GNU
1 error message format.
1
1 'histappend'
1 If set, the history list is appended to the file named by the
1 value of the 'HISTFILE' variable when the shell exits, rather
1 than overwriting the file.
1
1 'histreedit'
1 If set, and Readline is being used, a user is given the
1 opportunity to re-edit a failed history substitution.
1
1 'histverify'
1 If set, and Readline is being used, the results of history
1 substitution are not immediately passed to the shell parser.
1 Instead, the resulting line is loaded into the Readline
1 editing buffer, allowing further modification.
1
1 'hostcomplete'
1 If set, and Readline is being used, Bash will attempt to
1 perform hostname completion when a word containing a '@' is
1 being completed (⇒Commands For Completion). This
1 option is enabled by default.
1
1 'huponexit'
1 If set, Bash will send 'SIGHUP' to all jobs when an
1 interactive login shell exits (⇒Signals).
1
1 'inherit_errexit'
1 If set, command substitution inherits the value of the
1 'errexit' option, instead of unsetting it in the subshell
1 environment. This option is enabled when POSIX mode is
1 enabled.
1
1 'interactive_comments'
1 Allow a word beginning with '#' to cause that word and all
1 remaining characters on that line to be ignored in an
1 interactive shell. This option is enabled by default.
1
1 'lastpipe'
1 If set, and job control is not active, the shell runs the last
1 command of a pipeline not executed in the background in the
1 current shell environment.
1
1 'lithist'
1 If enabled, and the 'cmdhist' option is enabled, multi-line
1 commands are saved to the history with embedded newlines
1 rather than using semicolon separators where possible.
1
1 'login_shell'
1 The shell sets this option if it is started as a login shell
1 (⇒Invoking Bash). The value may not be changed.
1
1 'mailwarn'
1 If set, and a file that Bash is checking for mail has been
1 accessed since the last time it was checked, the message '"The
1 mail in MAILFILE has been read"' is displayed.
1
1 'no_empty_cmd_completion'
1 If set, and Readline is being used, Bash will not attempt to
1 search the 'PATH' for possible completions when completion is
1 attempted on an empty line.
1
1 'nocaseglob'
1 If set, Bash matches filenames in a case-insensitive fashion
1 when performing filename expansion.
1
1 'nocasematch'
1 If set, Bash matches patterns in a case-insensitive fashion
1 when performing matching while executing 'case' or '[['
1 conditional commands, when performing pattern substitution
1 word expansions, or when filtering possible completions as
1 part of programmable completion.
1
1 'nullglob'
1 If set, Bash allows filename patterns which match no files to
1 expand to a null string, rather than themselves.
1
1 'progcomp'
11 If set, the programmable completion facilities (⇒
Programmable Completion) are enabled. This option is
1 enabled by default.
1
1 'promptvars'
1 If set, prompt strings undergo parameter expansion, command
1 substitution, arithmetic expansion, and quote removal after
11 being expanded as described below (⇒Controlling the
Prompt). This option is enabled by default.
1
1 'restricted_shell'
1 The shell sets this option if it is started in restricted mode
1 (⇒The Restricted Shell). The value may not be changed.
1 This is not reset when the startup files are executed,
1 allowing the startup files to discover whether or not a shell
1 is restricted.
1
1 'shift_verbose'
1 If this is set, the 'shift' builtin prints an error message
1 when the shift count exceeds the number of positional
1 parameters.
1
1 'sourcepath'
1 If set, the 'source' builtin uses the value of 'PATH' to find
1 the directory containing the file supplied as an argument.
1 This option is enabled by default.
1
1 'xpg_echo'
1 If set, the 'echo' builtin expands backslash-escape sequences
1 by default.
1
1 The return status when listing options is zero if all OPTNAMES are
1 enabled, non-zero otherwise. When setting or unsetting options,
1 the return status is zero unless an OPTNAME is not a valid shell
1 option.
1