shopt-option

compat43 shell option

Permits a break inside a function to affect the calling loop in legacy mode. Avoid relying on this cross-function control flow. This historical shopt spelling is accepted by the installed Bash 5.2.37; BASH_COMPAT=43 is the preferred selector. Compatibility settings are mutually exclusive and can include behavior of later thresholds. They do not install or emulate all features of an older binary. Run in a fresh private directory with HOME set to that directory and LC_ALL=C. Expected output (one item per line): level=43; same interpreter; loop ended.

Formal Syntax & Structure

bash syntaxbash
shopt -s compat43; shopt -u compat43

Return Value

exit status

Setting or clearing an available option succeeds; a query returns zero when enabled and one when disabled.

Working Example

Example Snippetbash
before=$BASH_VERSIONshopt -s compat43 || exit 1[[ $BASH_COMPAT == 43 ]] || exit 1printf 'level=%s\n' "$BASH_COMPAT"[[ $before == "$BASH_VERSION" ]] || exit 1printf 'same interpreter\n' f() { break; }for i in 1 2; do f; printf 'unexpected\n'; doneprintf 'loop ended\n'
Bash Reference