concept
Bash dynamic scope
Variable lookup follows active calls; a called function can read or mutate a visible caller local unless shadowed.
Formal Syntax & Structure
bash syntaxbash
local name=valueReturn Value
exit status
Variable lookup follows active calls; a called function can read or mutate a visible caller local unless shadowed.
Working Example
Example Snippetbash
label=globalinner() { printf 'seen=%s\n' "$label"; label=changed; }outer() { local label=outer inner printf 'outer=%s\n' "$label"}outerprintf 'global=%s\n' "$label"