Is there a POSIX Compliant way to limit the scope of a variable to the function it is declared in? i.e.:
Testing()
{
TEST=\"testing\"
}
Testing
echo \"T
Dude. You guys are going crazy with all this! This is built into the design of POSIX functions declarations.
If you would like a variable declared in the parent scope, to be accessible in a function, but leave its value in the parent scope unchanged, simply:
Declare your function using an explicit subshell, i.e., use a
subshell_function_declaration()
(
with=parentheses
)
, notinlined_function_declarations()
{
with=braces
;}
Which is the same behavior of inline grouping vs. subshell grouping, throughout the entire language. BTW.
{ [ $that = $is ] && how=grouping_works || ! $SHELL ;} || (exit 1)
, y'know?