shopt Options

The shopt options are set with shopt -s arg and unset with shopt -u arg. See Table 2.7 for options to shopt. 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.

Table B-7. Options to shopt

Option Meaning if Set
cdable_vars

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.

cdspell

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.

checkhash

Commands found in the hash table are checked for existence before being executed and non-existence forces a PATH search.

checkwinsize

Checks the window size after each command and, if it has changed, updates the variables LINES and COLUMNS accordingly.

cmdhist

Attempt to save all lines of a multiline command in a single history entry.

dotglob

Filenames beginning with a . are included in pathname expansion.

execfail

A non-interactive shell will not exit if it cannot execute the argument to an exec. Interactive shells do not exit if ...

Get Learning the bash Shell, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.