I read this today
"Local can only be used within a function; it makes the variable name have a visible scope restricted to that function and its children." The ABS Guide author considers this behavior to be a bug.
and I came up with this script
begin () {
  local foo
  alpha
}
alpha () {
  foo=333 bar=444
  bravo
}
bravo () {
  printf 'foo %3s bar %s\n' "$foo" "$bar"
}
begin
bravo
Output
foo 333 bar 444
foo     bar 444
So as you can see, because I did not local bar, it leaked out into global
scope. Questions:
- Is a local variable being available to a child function actually a bug, or was that just his opinion?
- Does Bash have a way to mark everything local, similar to how set -amarks everything for export?
- Failing that, does Bash have a way I can check for these leaked global variables?