TheBonsai 1195503774 learn http://bash-hackers.org/wiki/doku.php/scripting/basics#variable_scope lhunath 1405959834 forget lhunath 1405959923 learn All variables are global to the script by default. local/declare/typeset inside a function makes the variable local to the function. Use subshells (eg. (), $(), ...) if you need an explicit scope. http://wiki.bash-hackers.org/scripting/basics#variable_scope greycat 1605113435 forget greycat 1605113437 learn local/declare/typeset in a function makes a variable local to the function. All other variables are resolved using dynamic scope (look in the calling function's local vars, then the caller's caller's vars, etc. up to the global scope). Subshells also create an implicit scope.