| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
4.3.2 The Shopt Builtin
This builtin allows you to change additional shell optional behavior.
shopt-
shopt [-pqsu] [-o] [optname …]
Toggle the values of settings controlling optional shell behavior. The settings can be either those listed below, or, if the ‘-o’ option is used, those available with the ‘-o’ option to the
setbuiltin command (see section The Set Builtin). With no options, or with the ‘-p’ option, a list of all settable options is displayed, with an indication of whether or not each is set. The ‘-p’ option causes output to be displayed in a form that may be reused as input. Other options have the following meanings:-sEnable (set) each optname.
-uDisable (unset) each optname.
-qSuppresses normal output; the return status indicates whether the optname is set or unset. If multiple optname arguments are given with ‘-q’, the return status is zero if all optnames are enabled; non-zero otherwise.
-oRestricts the values of optname to be those defined for the ‘-o’ option to the
setbuiltin (see section The Set Builtin).
If either ‘-s’ or ‘-u’ is used with no optname arguments,
shoptshows only those options which are set or unset, respectively.Unless otherwise noted, the
shoptoptions are disabled (off) by default.The return status when listing options is zero if all optnames are enabled, non-zero otherwise. When setting or unsetting options, the return status is zero unless an optname is not a valid shell option.
The list of
shoptoptions is:autocdIf set, a command name that is the name of a directory is executed as if it were the argument to the
cdcommand. This option is only used by interactive shells.cdable_varsIf this is set, an argument to the
cdbuiltin command that is not a directory is assumed to be the name of a variable whose value is the directory to change to.cdspellIf set, minor errors in the spelling of a directory component in a
cdcommand will be corrected. The errors checked for are transposed characters, a missing character, and a character too many. If a correction is found, the corrected path is printed, and the command proceeds. This option is only used by interactive shells.checkhashIf this is set, Bash checks that a command found in the hash table exists before trying to execute it. If a hashed command no longer exists, a normal path search is performed.
checkjobsIf set, Bash lists the status of any stopped and running jobs before exiting an interactive shell. If any jobs are running, this causes the exit to be deferred until a second exit is attempted without an intervening command (see section Job Control). The shell always postpones exiting if any jobs are stopped.
checkwinsizeIf set, Bash checks the window size after each command and, if necessary, updates the values of
LINESandCOLUMNS.cmdhistIf set, Bash attempts to save all lines of a multiple-line command in the same history entry. This allows easy re-editing of multi-line commands.
compat31If set, Bash changes its behavior to that of version 3.1 with respect to quoted arguments to the conditional command’s ‘=~’ operator and with respect to locale-specific string comparison when using the
[[conditional command’s ‘<’ and ‘>’ operators. Bash versions prior to bash-4.1 use ASCII collation and strcmp(3); bash-4.1 and later use the current locale’s collation sequence and strcoll(3).compat32If set, Bash changes its behavior to that of version 3.2 with respect to locale-specific string comparison when using the
[[conditional command’s ‘<’ and ‘>’ operators (see previous item).compat40If set, Bash changes its behavior to that of version 4.0 with respect to locale-specific string comparison when using the
[[conditional command’s ‘<’ and ‘>’ operators (see description ofcompat31) and the effect of interrupting a command list. Bash versions 4.0 and later interrupt the list as if the shell received the interrupt; previous versions continue with the next command in the list.compat41If set, Bash, when in POSIX mode, treats a single quote in a double-quoted parameter expansion as a special character. The single quotes must match (an even number) and the characters between the single quotes are considered quoted. This is the behavior of POSIX mode through version 4.1. The default Bash behavior remains as in previous versions.
compat42If set, Bash does not process the replacement string in the pattern substitution word expansion using quote removal.
complete_fullquoteIf set, Bash quotes all shell metacharacters in filenames and directory names when performing completion. If not set, Bash removes metacharacters such as the dollar sign from the set of characters that will be quoted in completed filenames when these metacharacters appear in shell variable references in words to be completed. This means that dollar signs in variable names that expand to directories will not be quoted; however, any dollar signs appearing in filenames will not be quoted, either. This is active only when bash is using backslashes to quote completed filenames. This variable is set by default, which is the default Bash behavior in versions through 4.2.
direxpandIf set, Bash replaces directory names with the results of word expansion when performing filename completion. This changes the contents of the readline editing buffer. If not set, Bash attempts to preserve what the user typed.
dirspellIf set, Bash attempts spelling correction on directory names during word completion if the directory name initially supplied does not exist.
dotglobIf set, Bash includes filenames beginning with a ‘.’ in the results of filename expansion.
execfailIf this is set, a non-interactive shell will not exit if it cannot execute the file specified as an argument to the
execbuiltin command. An interactive shell does not exit ifexecfails.expand_aliasesIf set, aliases are expanded as described below under Aliases, Aliases. This option is enabled by default for interactive shells.
extdebugIf set, behavior intended for use by debuggers is enabled:
-
The ‘-F’ option to the
declarebuiltin (see section Bash Builtin Commands) displays the source file name and line number corresponding to each function name supplied as an argument. -
If the command run by the
DEBUGtrap returns a non-zero value, the next command is skipped and not executed. -
If the command run by the
DEBUGtrap returns a value of 2, and the shell is executing in a subroutine (a shell function or a shell script executed by the.orsourcebuiltins), a call toreturnis simulated. -
BASH_ARGCandBASH_ARGVare updated as described in their descriptions (see section Bash Variables). -
Function tracing is enabled: command substitution, shell functions, and
subshells invoked with
( command )inherit theDEBUGandRETURNtraps. -
Error tracing is enabled: command substitution, shell functions, and
subshells invoked with
( command )inherit theERRtrap.
-
The ‘-F’ option to the
extglobIf set, the extended pattern matching features described above (see section Pattern Matching) are enabled.
extquoteIf set,
$'string'and$"string"quoting is performed within${parameter}expansions enclosed in double quotes. This option is enabled by default.failglobIf set, patterns which fail to match filenames during filename expansion result in an expansion error.
force_fignoreIf set, the suffixes specified by the
FIGNOREshell variable cause words to be ignored when performing word completion even if the ignored words are the only possible completions. See section Bash Variables, for a description ofFIGNORE. This option is enabled by default.globasciirangesIf set, range expressions used in pattern matching bracket expressions (see section Pattern Matching) behave as if in the traditional C locale when performing comparisons. That is, the current locale’s collating sequence is not taken into account, so ‘b’ will not collate between ‘A’ and ‘B’, and upper-case and lower-case ASCII characters will collate together.
globstarIf set, the pattern ‘**’ used in a filename expansion context will match all files and zero or more directories and subdirectories. If the pattern is followed by a ‘/’, only directories and subdirectories match.
gnu_errfmtIf set, shell error messages are written in the standard GNU error message format.
histappendIf set, the history list is appended to the file named by the value of the
HISTFILEvariable when the shell exits, rather than overwriting the file.histreeditIf set, and Readline is being used, a user is given the opportunity to re-edit a failed history substitution.
histverifyIf set, and 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.
hostcompleteIf set, and Readline is being used, Bash will attempt to perform hostname completion when a word containing a ‘@’ is being completed (@pxref{Commands For Completion}). This option is enabled by default.
huponexitIf set, Bash will send
SIGHUPto all jobs when an interactive login shell exits (see section Signals).interactive_commentsAllow a word beginning with ‘#’ to cause that word and all remaining characters on that line to be ignored in an interactive shell. This option is enabled by default.
lastpipeIf set, and job control is not active, the shell runs the last command of a pipeline not executed in the background in the current shell environment.
lithistIf enabled, and the
cmdhistoption is enabled, multi-line commands are saved to the history with embedded newlines rather than using semicolon separators where possible.login_shellThe shell sets this option if it is started as a login shell (see section Invoking Bash). The value may not be changed.
mailwarnIf set, and a file that Bash is checking for mail has been accessed since the last time it was checked, the message
"The mail in mailfile has been read"is displayed.no_empty_cmd_completionIf set, and Readline is being used, Bash will not attempt to search the
PATHfor possible completions when completion is attempted on an empty line.nocaseglobIf set, Bash matches filenames in a case-insensitive fashion when performing filename expansion.
nocasematchIf set, Bash matches patterns in a case-insensitive fashion when performing matching while executing
caseor[[conditional commands.nullglobIf set, Bash allows filename patterns which match no files to expand to a null string, rather than themselves.
progcompIf set, the programmable completion facilities (@pxref{Programmable Completion}) are enabled. This option is enabled by default.
promptvarsIf set, prompt strings undergo parameter expansion, command substitution, arithmetic expansion, and quote removal after being expanded as described below (see section Controlling the Prompt). This option is enabled by default.
restricted_shellThe shell sets this option if it is started in restricted mode (see section The Restricted Shell). The value may not be changed. This is not reset when the startup files are executed, allowing the startup files to discover whether or not a shell is restricted.
shift_verboseIf this is set, the
shiftbuiltin prints an error message when the shift count exceeds the number of positional parameters.sourcepathIf set, the
sourcebuiltin uses the value ofPATHto find the directory containing the file supplied as an argument. This option is enabled by default.xpg_echoIf set, the
echobuiltin expands backslash-escape sequences by default.
The return status when listing options is zero if all optnames are enabled, non-zero otherwise. When setting or unsetting options, the return status is zero unless an optname is not a valid shell option.
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated on February 28, 2014 using texi2html 5.0.
