-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Work around Windows bug https://github.com/microsoft/terminal/issues/15212 #19212
Work around Windows bug https://github.com/microsoft/terminal/issues/15212 #19212
Conversation
…n is broken, by attempting to look up emcc first in EMSCRIPTEN, and then in PATH if it cannot be expanded to via %~dp0. Add a new test other.test_windows_batch_file_dp0_expansion_bug to check for this scenario.
Fixes #19207 |
The problem with this workaround is that it could end up running a different version of the tool. For example, imagine I have How common is this use case do you think? Could we instead simply error out with suggestions on how to fix? Alternatively can we work towards dropping these |
True.
Calling The bug only occurs if you call
Actually now that I think about this, I wonder why people would ever need to invoke
I looked into this, but unfortunately at least .ps1 files are not possible, because they are not executable on Windows. I.e. calling "emcc" will not invoke "emcc.ps1", which is the very purpose of these bat scripts.
This might be possible. |
c193602
to
95b5410
Compare
Actually, now sleeping on this, I realize that the only condition when this bug occurs is if one calls The bug does not occur if one calls So it then stands to reason that if "%~dp0\emcc" does not locate the bat script, then looking up in PATH will repeat the same search as the calling shell did, and it will find the same emcc.bat file. Changed this PR to remove the lookup to the EMSCRIPTEN environment variable. With this change the lookup is correct with no possibility of finding the wrong Emscripten. |
test/runner.bat
Outdated
set MYDIR=%~dp0 | ||
goto FOUND_MYDIR | ||
) | ||
for %%I in (%~n0.bat) do ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this for loop looping over?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is looping over an array of length 1, that has the string "%~n0.bat"
as its only entry.
This is because the construct set MYDIR=%%~dp$PATH:I
can only be invoked for a variable I
that has been created as an iterator variable in a for
statement.
emdump.bat
Outdated
set MYDIR=%~dp0 | ||
goto FOUND_MYDIR | ||
) | ||
for %%I in (tools\emdump.bat) do ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line looks different to the other? Do you need to run ./tools/create_entry_points.py
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is due to a construct in tools\create_entry_points.py
that does
# For some tools the entry point doesn't live alongside the python
# script.
entry_remap = {
'emdump': 'tools/emdump',
'emprofile': 'tools/emprofile',
'emdwp': 'tools/emdwp',
'emnm': 'tools/emnm',
}
...
if entry_point in entry_remap:
bat_data = bat_data.replace('%~n0', entry_remap[entry_point].replace('/', '\\'))
It is ok even if these look different. We could replace %~n0 in all scripts, not just the ones in tools/ , but that can be a separate improvement if so desired.
Work around Windows bug microsoft/terminal#15212 where %~dp0 expansion is broken, by attempting to look up emcc
first in EMSCRIPTEN, and thenin PATH if it cannot be expanded to via %~dp0.Add a new test other.test_windows_batch_file_dp0_expansion_bug to check for this scenario.