Start up the Interpreter, type in i=0; and add the following function:
increment () {i++;}
No matter how many times increment is invoked, it doesn't alter the global value of i. If you try changing the function to j, it will complain about j not existing.
This doesn't work either.
ii = 0;
for (ii=0 ; ii < 10; ii++)
{
print (ii);
}
print ("after the loop:" + ii);
The result is 0 rather than 10.
Logged In: YES
user_id=18885
This isn't actually a bug, but is a confusing aspect of the
way bsh deals with variables. All variable assignment is
local unless you scope it. Bsh is simply incrementing the
value in the local scope.
I will add better documentation of this confusing aspect of
bsh. If developers want to talk about this (after perhaps
reading the email discussions or write-up) please let me
know. I'm open to suggestions... but there are reasons
why this is so. --Pat
The follow up looks like bug #418202 or related (for scope
issue).