builtin

Bash shopt — inspect and change Bash options

Controls Bash-specific options such as nullglob. -s enables, -u disables, -q tests without printing, and -p prints commands representing settings. With -o it operates on set -o option names. In query mode a disabled option yields nonzero; do not treat every nonzero query as an unexpected error. Run in a fresh private directory with HOME set to that directory and LC_ALL=C. Expected output (one item per line): enabled=0; disabled=1.

Formal Syntax & Structure

bash syntaxbash
shopt [-pqsu] [-o] [optname ...]

Parameters & Attributes

NameTypeDescription
optnameoption nameOption to inspect or change.
flagsoptionsSelect query, enable, disable or display behavior.

Return Value

exit status

Zero on success; nonzero on failure.

Working Example

Example Snippetbash
shopt -s nullglobshopt -q nullglob; printf 'enabled=%s\n' "$?"shopt -u nullglobshopt -q nullglob; printf 'disabled=%s\n' "$?"
Bash Reference