You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Joachim Ansorg edited this page Nov 12, 2021
·
2 revisions
local is only valid in functions.
Problematic code:
local foo=bar
echo"$foo"
Correct code:
foo=bar
echo"$foo"
Rationale:
In Bash, local can only be used in functions. In other contexts, it's an error.
Exceptions:
It's possible to source files containing local from a function context but not from any other context. This is not good practice, but in these cases you can ignore this error.