Softpanorama

May the source be with you, but remember the KISS principle ;-)
Home Switchboard Unix Administration Red Hat TCP/IP Networks Neoliberalism Toxic Managers
(slightly skeptical) Educational society promoting "Back to basics" movement against IT overcomplexity and  bastardization of classic Unix

Bash options

This information was taken from a Bash version "4.1", every now and then new options are added, so likely, this list isn't complete.

The shell-options can be set with the shopt builtin command.

Bash options

autocd

Option: autocd Since: 4.0-alpha
Shell mode: interactive only Default: off

If set, a command name that is the name of a directory is executed as if it were the argument to the cd command.

cdable_vars

Option: cdable_vars Since: unknown
Shell mode: all Default: off

Treat every non-directory argument to the cd-command as variable name containing a directory to cd into.

cdspell

Option: cdspell Since: unknown
Shell mode: interactive only Default: off

If set, minor errors in the spelling of a directory component in a cd command will be corrected. The errors checked for are transposed characters, a missing character, and one character too many. If a correction is found, the corrected file name is printed, and the command proceeds.

checkhash

Option: checkhash Since: unknown
Shell mode: all Default: off

If 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.

checkjobs

Option: checkjobs Since: 4.0-alpha
Shell mode: interactive only Default: off

If 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. The shell always postpones exiting if any jobs are stopped.

checkwinsize

Option: checkwinsize Since: unknown
Shell mode: all Default: off

If set, Bash checks the window size after each command and, if necessary, updates the values of the variables LINES and COLUMNS.

cmdhist

Option: cmdhist Since: unknown
Shell mode: all Default: off

If 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.

compat31

Option: compat31 Since: 3.2
Shell mode: all Default: off

Compatiblity mode for Bash 3.1

compat32

Option: compat32 Since: 4.0
Shell mode: all Default: off

Compatiblity mode for Bash 3.2

compat40

Option: compat40 Since: 4.1-beta
Shell mode: all Default: off

Compatiblity mode for Bash 4.0

compat41

Option: compat41 Since: 4.2-alpha
Shell mode: all Default: off

Compatiblity mode for Bash 4.1

direxpand

Option: direxpand Since: 4.3-alpha
Shell mode: all Default: off (unless changed on compile-time with –enable-direxpand-default)

If 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.

dirspell

Option: dirspell Since: 4.0-alpha
Shell mode: all Default: off

If set, Bash will perform spelling corrections on directory names to match a glob.

dotglob

Option: dotglob Since: unknown
Shell mode: all Default: off

If set, Bash includes filenames beginning with a . (dot) in the results of pathname expansion.

execfail

Option: execfail Since: unknown
Shell mode: non-interactive Default: off

If set, a non-interactive shell will not exit if it cannot execute the file specified as an argument to the exec-builtin command. An interactive shell does not exit if exec fails.

expand_aliases

Option: expand_aliases Since: unknown
Shell mode: all Default: on (interactive), off (non-interactive)

If set, aliases are expanded. This option is enabled by default for interactive shells.

extdebug

Option: extdebug Since: 3.0-alpha
Shell mode: all Default: off

If set, behavior intended for use by debuggers is enabled.

extglob

Option: extglob Since: 2.02-alpha1
Shell mode: all Default: off

If set, the extended pattern matching features are enabled. See the important note below under Parser configurations.

extquote

Option: extquote Since: 3.0-alpha (?)
Shell mode: all Default: on

If set, $'string' and $"string" quoting is performed within parameter expansions enclosed in double quotes. See the important note below under Parser configurations.

failglob

Option: failglob Since: 3.0-alpha
Shell mode: all Default: off

If set, patterns which fail to match filenames during pathname expansion result in an error message.

force_fignore

Option: force_fignore Since: 3.0-alpha
Shell mode: interactive (?) Default: on

If set, the suffixes specified by the FIGNORE shell variable cause words to be ignored when performing word completion even if the ignored words are the only possible completions. This option is enabled by default.

globasciiranges

Option: globasciiranges Since: 4.3-alpha
Shell mode: all Default: off

If set, range expressions used in 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.

globstar

Option: globstar Since: 4.0-alpha
Shell mode: all Default: off

If set, recursive globbing with ** is enabled.

gnu_errfmt

Option: gnu_errfmt Since: 3.0-alpha
Shell mode: all Default: off

If set, shell error messages are written in the "standard GNU error message format".

histappend

Option: histappend Since: unknown
Shell mode: interactive (?) Default: off

If set, the history list is appended to the file named by the value of the HISTFILE variable when the shell exits, rather than overwriting the file.

histreedit

Option: histreedit Since: unknown
Shell mode: interactive (?) Default: off

If set, and readline is being used, a user is given the opportunity to re-edit a failed history substitution.

histverify

Option: histverify Since: unknown
Shell mode: interactive (?) Default: off

Allow to review a history substitution result by loading the resulting line into the editing buffer, rather than directly executing it.

hostcomplete

Option: hostcomplete Since: 2.0-alpha3
Shell mode: interactive (?) Default: on

If set, Bash completion also completes hostnames. On by default.

huponexit

Option: huponexit Since: 2.02-alpha1
Shell mode: interactive login Default: off

If set, Bash will send the SIGHUP signal to all jobs when an interactive login shell exits.

interactive_comments

Option: interactive_comments Since: unknown
Shell mode: interactive Default: on

Allow commenting in interactive shells, on by default.

lastpipe

Option: lastpipe Since: 4.2-alpha
Shell mode: all Default: off

If 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.

lithist

Option: lithist Since: unknown
Shell mode: interactive Default: off

If set, and the cmdhist option is enabled, multi-line commands are saved to the history with embedded newlines rather than using semicolon separators where possible.

login_shell

Option: login_shell Since: 2.05a-alpha1
Shell mode: all Default: n/a

The option is set when Bash is a login shell. This is a readonly option.

mailwarn

Option: mailwarn Since: unknown
Shell mode: interactive (?) Default: off

If 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_completion

Option: mailwarn Since: unknown
Shell mode: interactive (?) Default: off

If set, and readline is being used, Bash will not attempt to search the PATH for possible completions when completion is attempted on an empty line.

nocaseglob

Option: nocaseglob Since: 2.02-alpha1
Shell mode: interactive (?) Default: off

If set, Bash matches filenames in a case-insensitive fashion when performing pathname expansion.

nocasematch

Option: nocasematch Since: 3.1-alpha1
Shell mode: interactive (?) Default: off

If set, Bash matches patterns in a case-insensitive fashion when performing matching while executing case or [[ conditional commands.

nullglob

Option: nullglob Since: unknown
Shell mode: interactive (?) Default: off

If set, Bash allows patterns which match no files to expand to a null string, rather than themselves.

progcomp

Option: progcomp Since: 2.04-alpha1
Shell mode: interactive (?) Default: on

If set, the programmable completion facilities are enabled. This option is enabled by default.

promptvars

Option: promptvars Since: unknown
Shell mode: interactive (?) Default: on

If set, prompt strings undergo parameter expansion, command substitution, arithmetic expansion, and quote removal after being expanded using the prompt special sequences. This option is enabled by default.

restricted_shell

Option: restricted_shell Since: 2.03-alpha
Shell mode: interactive (?) Default: off

The option is set when Bash is a restricted shell. This is a readonly option.

shift_verbose

Option: shift_verbose Since: unknown
Shell mode: interactive (?) Default: off

If set, the shift builtin prints an error message when the shift count exceeds the number of positional parameters.

sourcepath

Option: sourcepath Since: unknown
Shell mode: interactive (?) Default: on

If set, the source builtin command uses the value of PATH to find the directory containing the file supplied as an argument. This option is enabled by default.

xpg_echo

Option: xpg_echo Since: 2.04-beta1
Shell mode: interactive (?) Default: off

If set, the echo-builtin command expands backslash-escape sequences by default (POSIX, SUS, XPG).

Parser configurations

Parser configurations change the way the Bash parser recognizes the syntax when parsing a line. This, of course, is impossible for a line that already was parsed.

There are two options that influence the parsing this way:

Consequence: You can't use the new syntax (e.g. the extended globbing syntax) and the command to enable it in the same line.

$ shopt -s extglob; echo !(*.txt) # this is the WRONG way!
-bash: syntax error near unexpected token `('

You have to configure the parser before a line with new syntax is parsed:

$ shopt -s extglob # standalone - CORRECT way!
$ echo !(*.txt)
...

See also

Juanma, 2015/04/17 14:21

The compat* variables are mentioned but not documented. My guess is that turning one of them on brings Bash to the behavior expected in that version. Am I right? I'm wondering because I can't make the regexp operator (=~) work as I expect, which means not doing this:

# re='[[:blank:]]*'; if [[ 'z' =~ $re ]]; then echo "match!"; fi
match!

or even this:

# re='[ ]*'; if [[ 'z' =~ $re ]]; then echo "match!"; fi
match!

Thanks to anyone willing to help.

Levi, 2015/08/21 12:07

You're matching the null string in front of and behind the 'z'. To get it to work properly, try:

$ re='^[[:blank:]]*$'; if [[ 'z' =~ $re ]]; then echo "match!"; fi
$ re='^[ ]*$'; if [[ 'z' =~ $re ]]; then echo "match!"; fi</pre>

Now the anchors will match the nothingness and the rest will have to match whatever's in between.

There's a very similar case in the camel book, which comes with a footnote saying:

Don't feel bad. Even the authors get caught by this from time to time.

Top Visited
Switchboard
Latest
Past week
Past month

NEWS CONTENTS

Old News ;-)

http://wiki.bash-hackers.org/start

http://wiki.bash-hackers.org/internals/shell_options

Recommended Links

Google matched content

Softpanorama Recommended

Top articles

Sites

Top articles

Sites

...



Etc

Society

Groupthink : Two Party System as Polyarchy : Corruption of Regulators : Bureaucracies : Understanding Micromanagers and Control Freaks : Toxic Managers :   Harvard Mafia : Diplomatic Communication : Surviving a Bad Performance Review : Insufficient Retirement Funds as Immanent Problem of Neoliberal Regime : PseudoScience : Who Rules America : Neoliberalism  : The Iron Law of Oligarchy : Libertarian Philosophy

Quotes

War and Peace : Skeptical Finance : John Kenneth Galbraith :Talleyrand : Oscar Wilde : Otto Von Bismarck : Keynes : George Carlin : Skeptics : Propaganda  : SE quotes : Language Design and Programming Quotes : Random IT-related quotesSomerset Maugham : Marcus Aurelius : Kurt Vonnegut : Eric Hoffer : Winston Churchill : Napoleon Bonaparte : Ambrose BierceBernard Shaw : Mark Twain Quotes

Bulletin:

Vol 25, No.12 (December, 2013) Rational Fools vs. Efficient Crooks The efficient markets hypothesis : Political Skeptic Bulletin, 2013 : Unemployment Bulletin, 2010 :  Vol 23, No.10 (October, 2011) An observation about corporate security departments : Slightly Skeptical Euromaydan Chronicles, June 2014 : Greenspan legacy bulletin, 2008 : Vol 25, No.10 (October, 2013) Cryptolocker Trojan (Win32/Crilock.A) : Vol 25, No.08 (August, 2013) Cloud providers as intelligence collection hubs : Financial Humor Bulletin, 2010 : Inequality Bulletin, 2009 : Financial Humor Bulletin, 2008 : Copyleft Problems Bulletin, 2004 : Financial Humor Bulletin, 2011 : Energy Bulletin, 2010 : Malware Protection Bulletin, 2010 : Vol 26, No.1 (January, 2013) Object-Oriented Cult : Political Skeptic Bulletin, 2011 : Vol 23, No.11 (November, 2011) Softpanorama classification of sysadmin horror stories : Vol 25, No.05 (May, 2013) Corporate bullshit as a communication method  : Vol 25, No.06 (June, 2013) A Note on the Relationship of Brooks Law and Conway Law

History:

Fifty glorious years (1950-2000): the triumph of the US computer engineering : Donald Knuth : TAoCP and its Influence of Computer Science : Richard Stallman : Linus Torvalds  : Larry Wall  : John K. Ousterhout : CTSS : Multix OS Unix History : Unix shell history : VI editor : History of pipes concept : Solaris : MS DOSProgramming Languages History : PL/1 : Simula 67 : C : History of GCC developmentScripting Languages : Perl history   : OS History : Mail : DNS : SSH : CPU Instruction Sets : SPARC systems 1987-2006 : Norton Commander : Norton Utilities : Norton Ghost : Frontpage history : Malware Defense History : GNU Screen : OSS early history

Classic books:

The Peter Principle : Parkinson Law : 1984 : The Mythical Man-MonthHow to Solve It by George Polya : The Art of Computer Programming : The Elements of Programming Style : The Unix Hater’s Handbook : The Jargon file : The True Believer : Programming Pearls : The Good Soldier Svejk : The Power Elite

Most popular humor pages:

Manifest of the Softpanorama IT Slacker Society : Ten Commandments of the IT Slackers Society : Computer Humor Collection : BSD Logo Story : The Cuckoo's Egg : IT Slang : C++ Humor : ARE YOU A BBS ADDICT? : The Perl Purity Test : Object oriented programmers of all nations : Financial Humor : Financial Humor Bulletin, 2008 : Financial Humor Bulletin, 2010 : The Most Comprehensive Collection of Editor-related Humor : Programming Language Humor : Goldman Sachs related humor : Greenspan humor : C Humor : Scripting Humor : Real Programmers Humor : Web Humor : GPL-related Humor : OFM Humor : Politically Incorrect Humor : IDS Humor : "Linux Sucks" Humor : Russian Musical Humor : Best Russian Programmer Humor : Microsoft plans to buy Catholic Church : Richard Stallman Related Humor : Admin Humor : Perl-related Humor : Linus Torvalds Related humor : PseudoScience Related Humor : Networking Humor : Shell Humor : Financial Humor Bulletin, 2011 : Financial Humor Bulletin, 2012 : Financial Humor Bulletin, 2013 : Java Humor : Software Engineering Humor : Sun Solaris Related Humor : Education Humor : IBM Humor : Assembler-related Humor : VIM Humor : Computer Viruses Humor : Bright tomorrow is rescheduled to a day after tomorrow : Classic Computer Humor

The Last but not Least Technology is dominated by two types of people: those who understand what they do not manage and those who manage what they do not understand ~Archibald Putt. Ph.D


Copyright © 1996-2021 by Softpanorama Society. www.softpanorama.org was initially created as a service to the (now defunct) UN Sustainable Development Networking Programme (SDNP) without any remuneration. This document is an industrial compilation designed and created exclusively for educational use and is distributed under the Softpanorama Content License. Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.

FAIR USE NOTICE This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. We are making such material available to advance understanding of computer science, IT technology, economic, scientific, and social issues. We believe this constitutes a 'fair use' of any such copyrighted material as provided by section 107 of the US Copyright Law according to which such material can be distributed without profit exclusively for research and educational purposes.

This is a Spartan WHYFF (We Help You For Free) site written by people for whom English is not a native language. Grammar and spelling errors should be expected. The site contain some broken links as it develops like a living tree...

You can use PayPal to to buy a cup of coffee for authors of this site

Disclaimer:

The statements, views and opinions presented on this web page are those of the author (or referenced source) and are not endorsed by, nor do they necessarily reflect, the opinions of the Softpanorama society. We do not warrant the correctness of the information provided or its fitness for any purpose. The site uses AdSense so you need to be aware of Google privacy policy. You you do not want to be tracked by Google please disable Javascript for this site. This site is perfectly usable without Javascript.

Last modified: March, 12, 2019