Is bash not working the way you want it to? Change the way it behaves with this handy list of options from Arnold Robbins' bash Pocket Reference.
Bash provides a number of shell options, settings that you can change to modify the shell’s behavior. You control these options with the shopt command (see the entry for shopt). The following descriptions describe the behavior when set. Options marked with a dagger (†) are enabled by default:
autocdWhen the first word of a simple command cannot be executed, try to cd to it.
cdable_varsTreat a nondirectory argument to cd as a variable whose value is the directory to go to.
cdspellAttempt spelling correction on each directory component of an argument to cd. Allowed in interactive shells only.
checkhashCheck that commands found in the hash table still exist before attempting to use them. If not, perform a normal
PATHsearch.checkjobsWhen an attempt is made to exit a shell and there are stopped or running background jobs, the shell prints
Therearerunningjobs. and a list of jobs and their statuses. A second exit attempt (such as typing EOF again) causes the shell to exit.checkwinsizeCheck the window size after each command, and update
LINESandCOLUMNSif the size has changed.cmdhist†Save all lines of a multiline command in one history entry. This permits easy re-editing of multiline commands.
compat31Mutually exclusive with the
compat32andcompat40options. Restore the behavior of the=~operator for the[[ ]]command whereby the righthand side is always treated as a regular expression to be matched. In addition, the<and>operators ignore the locale when doing string comparison.compat32Mutually exclusive with the
compat31andcompat40options. Cause the<and>operators of the[[ ]]command to ignore the locale when doing string comparison.compat40Mutually exclusive with the
compat31andcompat32options. Cause the<and>operators of the[[ ]]command to ignore the locale when doing string comparison. In addition, interrupting a command list such ascmd1; cmd2; cmd3aborts execution of the entire list. (Prior to version 4.0, interrupting one command in a list did not prevent the following commands from executing.)dirspellAttempt spelling correction on directory names during word completion if the name as given does not exist.
dotglobInclude filenames starting with a period in the results of filename expansion.
execfailDo not exit a noninteractive shell if the command given to exec cannot be executed. Interactive shells do not exit in such a case, no matter the setting of this option.
expand_aliases†Expand aliases created with alias. Disabled in noninteractive shells.
extdebugEnable behavior needed for debuggers:
declare -Fdisplays the source filename and line number for each function name argument.When a command run by the
DEBUGtrap fails, the next command is skipped.When a command run by the
DEBUGtrap inside a shell function or script sourced with . (dot) or source returns with an exit status of 2, the shell simulates a call to return.BASH_ARGCandBASH_ARGVare set as described earlier.Function tracing is enabled. Command substitutions, shell functions, and subshells invoked via
(…)inherit theDEBUGandRETURNtraps.Error tracing is enabled. Command substitutions, shell functions, and subshells invoked via
(…)inherit theERRtrap.
extglobEnable extended pattern-matching facilities such as
+(…). (These were not in the Bourne shell and are not in POSIX; thus Bash requires you to enable them if you want them.)extquote†Allow
$'…'and$"…"within${variable}expansions inside double quotes.failglobCause patterns that do not match filenames to produce an error.
force_fignore†When doing completion, ignore words matching the list of suffixes in
FIGNORE, even if such words are the only possible completions.globstar†Enable extended directory and subdirectory matching with the special
**pattern.gnu_errfmtPrint error messages in the standard GNU format. Enabled automatically when Bash runs in an Emacs terminal window.
histappendAppend the history list to the file named by
$HISTFILEupon exit, instead of overwriting the file.histreeditAllow a user to re-edit a failed
csh-style history substitution with the readline library.histverifyPlace the results of csh-style history substitution into the readline library’s editing buffer instead of executing it directly, in case the user wishes to modify it further.
hostcomplete†If using readline, attempt hostname completion when a word containing an
@is being completed.huponexitSend a
SIGHUPto all running jobs upon exiting an interactive login shell.interactive_comments†Allow words beginning with
#to start a comment in an interactive shell.lithistIf
cmdhistis also set, save multiline commands to the history file with newlines instead of semicolons.login_shellSet by the shell when it is a login shell. This is a read-only option.
mailwarnPrint the message
The mail inmailfilehas been readwhen a file being checked for mail has been accessed since the last time Bash checked it.no_empty_cmd_completionIf using readline, do not search
$PATHwhen a completion is attempted on an empty line, or a line consisting solely of whitespace.nocaseglobIgnore letter case when doing filename matching.
nocasematchIgnore letter case when doing pattern matching for
caseand[[ ]].nullglobExpand patterns that do not match any files to the null string, instead of using the literal pattern as an argument.
progcomp†Enable programmable completion.
promptvars†Perform variable, command, and arithmetic substitution on the values of
PS1,PS2, andPS4.restricted_shellSet by the shell when it is a restricted shell. This is a read-only option.
shift_verboseCauses shift to print an error message when the shift count is greater than the number of positional parameters.
sourcepath†Causes the . (dot) and source commands to search
$PATHin order to find the file to read and execute.xpg_echoCauses echo to expand escape sequences, even without the
-eor-Eoptions.
You need to know how to work with the bash shell if you want to get to the heart of Unix systems, including Linux and Mac OS X. Now covering the most recent version of bash, this concise little book puts all of the essential information about bash at your fingertips. You'll quickly find answers to annoying questions that always come up when you're writing shell scripts -- What characters do you need to quote? How do you get variable substitution to do exactly what you want? How do you use arrays? -- and much more.




Help









