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=value

Return 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"
Bash Reference