Variable Scoping
Another hiddem gem in BASH, is that you can scope variables,
using thelocal
keyword:
my_variable="Global value"
function my_function()
{
local my_variable="My function local value"
echo "my_variable=$my_variable"
}
my_function
echo "my_variable=$my_variable"
my_function