invocation-option

Bash -O option

Enables a named shopt setting before reading script source. Useful for syntax-affecting options such as extglob, including during syntax-only checks. The option name must be supported by the installed Bash release. Run in a fresh private directory with HOME set to that directory and LC_ALL=C. Expected output (one item per line): match.

Formal Syntax & Structure

bash syntaxbash
bash -O option

Parameters & Attributes

NameTypeDescription
optionstringSupported shopt option.

Return Value

exit status

See the example and command status; failures are nonzero.

Working Example

Example Snippetbash
printf '%s\n' 'case item in @(item|other)) printf "match\n" ;; esac' > input.shbash --noprofile --norc -O extglob -n input.sh || exit 1bash --noprofile --norc -O extglob input.sh
Bash Reference