====== Bash Variables ======
===== Local Variables =====
foo=one
printvalue() {
local foo=two
echo $foo
}
# This will print ''one'' to the console.
echo $foo
# This will print ''two'' to the console.
printvalue
# This will print ''one'' to the console.
echo $foo
===== Environment Variables =====
One feature we will use for Scope is the system that exists in all Unix systems. For example, when we call a program in a script, all environment variables are copied into the scope of that program. In short, the variables we define in the called script can only be accessed if they are environment variables.
# create a new variable and set it:
# -> This is a normal variable, not an environment variable!
test_variable="Hello World."
# Let's make it visible to all sub-processes by converting it to an environment variable:
export test_variable
Taken from [[en:cs:bash:variable|UCH Wiki]].
===== EDITOR NOTES =====