|
5 | 5 | :: To make modifications to this file, edit `tools/run_python.bat` and then run |
6 | 6 | :: `tools/create_entry_points.py` |
7 | 7 |
|
| 8 | +:: N.b. In Windows .bat scripts, the ':' character cannot appear inside any if () blocks, |
| 9 | +:: or there will be a parsing error. |
| 10 | + |
8 | 11 | :: All env. vars specified in this file are to be local only to this script. |
9 | 12 | @setlocal |
10 | 13 | :: -E will not ignore _PYTHON_SYSCONFIGDATA_NAME an internal |
|
15 | 18 | set EM_PY=python |
16 | 19 | ) |
17 | 20 |
|
| 21 | +:: Work around Windows bug https://github.com/microsoft/terminal/issues/15212 : If this |
| 22 | +:: script is invoked via enclosing the invocation in quotes via PATH lookup, then %~f0 and |
| 23 | +:: %~dp0 expansions will not work. |
| 24 | +:: So first try if %~dp0 might work, and if not, manually look up this script from PATH. |
| 25 | +@if exist %~f0 ( |
| 26 | + set MYDIR=%~dp0 |
| 27 | + goto FOUND_MYDIR |
| 28 | +) |
| 29 | +@for %%I in (%~n0.bat) do ( |
| 30 | + @if exist %%~$PATH:I ( |
| 31 | + set MYDIR=%%~dp$PATH:I |
| 32 | + ) else ( |
| 33 | + echo Fatal Error! Due to a Windows bug, we are unable to locate the path to %~n0.bat. |
| 34 | + echo To help this issue, try removing unnecessary quotes in the invocation of emcc, |
| 35 | + echo or add Emscripten directory to PATH. |
| 36 | + echo See github.com/microsoft/terminal/issues/15212 and |
| 37 | + echo github.com/emscripten-core/emscripten/issues/19207 for more details. |
| 38 | + ) |
| 39 | +) |
| 40 | +:FOUND_MYDIR |
| 41 | + |
18 | 42 | :: Python Windows bug https://bugs.python.org/issue34780: If this script was invoked via a |
19 | 43 | :: shared stdin handle from the parent process, and that parent process stdin handle is in |
20 | 44 | :: a certain state, running python.exe might hang here. To work around this, if |
|
47 | 71 | ) |
48 | 72 |
|
49 | 73 | :NORMAL_EXIT |
50 | | -@"%EM_PY%" -E "%~dp0\%~n0.py" %* |
| 74 | +@"%EM_PY%" -E "%MYDIR%%~n0.py" %* |
51 | 75 | @exit %ERRORLEVEL% |
52 | 76 |
|
53 | 77 | :MUTE_STDIN |
54 | | -@"%EM_PY%" -E "%~dp0\%~n0.py" %* < NUL |
| 78 | +@"%EM_PY%" -E "%MYDIR%%~n0.py" %* < NUL |
55 | 79 | @exit /b %ERRORLEVEL% |
56 | 80 |
|
57 | 81 | :MUTE_STDIN_EXIT |
58 | | -@"%EM_PY%" -E "%~dp0\%~n0.py" %* < NUL |
| 82 | +@"%EM_PY%" -E "%MYDIR%%~n0.py" %* < NUL |
59 | 83 | @exit %ERRORLEVEL% |
60 | 84 |
|
61 | 85 | :NORMAL |
62 | | -@"%EM_PY%" -E "%~dp0\%~n0.py" %* |
| 86 | +@"%EM_PY%" -E "%MYDIR%%~n0.py" %* |
0 commit comments