shopt-option

localvar_inherit

A new local declaration can inherit the outer binding value and attributes except nameref. Explicit initialization remains preferable for predictable contracts.

Formal Syntax & Structure

bash syntaxbash
shopt -s localvar_inherit

Return Value

exit status

A new local declaration can inherit the outer binding value and attributes except nameref. Explicit initialization remains preferable for predictable contracts.

Working Example

Example Snippetbash
value=outerf() { local value; printf '[%s]\n' "$value"; }shopt -u localvar_inheritfshopt -s localvar_inheritf
Bash Reference