-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
local
and global
variables
#63
Comments
@shadichy could you provide some example input together with the expected output? |
like someFunc() {
aGlobalVar=1
local aLocalVar=1
} should returns something like :someFunc
set aGlobalVar=1
setlocal
set aLocalVar=1
endlocal
exit /b 0 |
@shadichy I see some problem with this approach (wrapping individual 'local' assignments with 'setlocal'/'endloacal'): When the variable is used in subsequent lines the value is gone - e.g. the following script ECHO OFF
setlocal
set aLocalVar="hello"
echo "inside first setlocal: %aLocalVar%"
endlocal
echo "outside setlocal: %aLocalVar%"
setlocal
echo "inside second setlocal: %aLocalVar%"
endlocal has the output "inside first setlocal: "hello""
"outside setlocal: "
"inside second setlocal: " And since 'local' and 'global' variables could occur in any order this is a problem - or did I miss something? |
@daniel-sc that's how 'local' variables work :) endlocal & (
set "GlobalVar1=%LocalVar1%"
set "GlobalVar2=%LocalVar2%"
set "GlobalVar3=%LocalVar3%"
) |
Yeah I understand. The point is, that a mere syntactically approach (as currently used) does not suffice to solve this. One would need to analyze all variables and their usages.. |
seems hard |
No description provided.
The text was updated successfully, but these errors were encountered: