global and local variables
suggest changeIntroduction
By default, every variable in Bash is global to every function in the same shell. A script that is executed (not sourced) does not change variables in the shell that started it.
If you want a variable to be local to a function, use local. That variable is independent of the global scope, and its value is accessible only inside that function.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents