Fix parentheses mix-up in batch files in Windows#13698
Merged
aheejin merged 4 commits intoemscripten-core:mainfrom Mar 20, 2021
Merged
Fix parentheses mix-up in batch files in Windows#13698aheejin merged 4 commits intoemscripten-core:mainfrom
aheejin merged 4 commits intoemscripten-core:mainfrom
Conversation
After emscripten-core#13498, `test_asyncify_onlylist_a` and `test_asyncify_onlylist_b` started to failing. emscripten-core#13498 introduced `if ( ... ) else ( ... )` in emcc/em++.bat, and it turns out the parentheses inside the command line can be mixed with those `if`-`else`'s parentheses themselves. This does not cause errors for every command line that contain parentheses, but when there are both a comma and parentheses, this can trigger errors. For example, `test_asyncify_onlylist_a`'s argument contains something like this: ``` 'ASYNCIFY_ONLY=["main",...,"foo(int,double)",...]' ``` Here the comma between `int` and `double` is mistaken as an item separator within the list, and `)` after `double` is consequently mistaken as ending `if`, because the whole body is within an `if`. This PR fixes the problem by assigning those argument `%*` into a variable `ARGS`, and within `if` and `else`, use it with a substitution of `)` with the escaped end-paren `^)`.
sbc100
reviewed
Mar 18, 2021
Collaborator
sbc100
left a comment
There was a problem hiding this comment.
Wow, pretty crazy looking syntax.
Can you end tools/run_python_compiler.bat and ru-run tools/create_entry_points.py?
Member
Author
|
Done. Didn't know they are copied from a template.. |
sbc100
approved these changes
Mar 18, 2021
aheejin
added a commit
to aheejin/emscripten
that referenced
this pull request
Mar 20, 2021
This issue was attempted to fix in emscripten-core#13698 by escaping `)` but it turned out to be an incomplete fix, because it fixed the breaking tests then but broke other ones instead depending on their syntax. This PR tries to fix it correctly by using `enabledelayedexpansion` feature of batch files. We can enable delayed expansion of variables within a batch file by ``` @SETLOCAL enabledelayedexpansion ``` And if you use variables not by the usual syntax `%VAR%` but `!VAR!`, it is expanded in a delayed manner, after all parentheses for `if`s and `else`s are expanded.
aheejin
added a commit
that referenced
this pull request
Mar 22, 2021
This issue was attempted to fix in #13698 by escaping `)` but it turned out to be an incomplete fix, because it fixed the breaking tests then but broke other ones instead depending on their syntax. This PR tries to fix it correctly by using `enabledelayedexpansion` feature of batch files. We can enable delayed expansion of variables within a batch file by ``` @SETLOCAL enabledelayedexpansion ``` And if you use variables not by the usual syntax `%VAR%` but `!VAR!`, it is expanded in a delayed manner, after all parentheses for `if`s and `else`s are expanded.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
After #13498,
test_asyncify_onlylist_aandtest_asyncify_onlylist_bstarted to failing. #13498 introduced
if ( ... ) else ( ... )inemcc/em++.bat, and it turns out the parentheses inside the command line
can be mixed with those
if-else's parentheses themselves. This doesnot cause errors for every command line that contain parentheses, but
when there are both a comma and parentheses, this can trigger errors.
For example,
test_asyncify_onlylist_a's argument contains somethinglike this:
Here the comma between
intanddoubleis mistaken as an itemseparator within the list, and
)afterdoubleis consequentlymistaken as ending
if, because the whole body is within anif.This PR fixes the problem by assigning those argument
%*into avariable
ARGS, and withinifandelse, use it with a substitutionof
)with the escaped end-paren^).