Skip to content

Commit 4e1e9fb

Browse files
authored
Make emrun work with file names containing space on Windows (emscripten-core#12385)
Essentially, if the first argument to the `cmd.exe` function `start` has quotes, it will be interpreted as the title of a new `cmd.exe` window instead of the command to execute. This can be fixed by specifying `""` as the first argument.
1 parent e5b741b commit 4e1e9fb

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

emrun.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,9 +1121,16 @@ def win_get_default_browser():
11211121
except WindowsError:
11221122
logv("Unable to find default browser key in Windows registry. Trying fallback.")
11231123

1124-
# Fall back to 'start %1', which we have to treat as if user passed --serve_forever, since
1124+
# Fall back to 'start "" %1', which we have to treat as if user passed --serve_forever, since
11251125
# for some reason, we are not able to detect when the browser closes when this is passed.
1126-
return ['cmd', '/C', 'start']
1126+
#
1127+
# If the first argument to 'start' is quoted, then 'start' will create a new cmd.exe window with
1128+
# that quoted string as the title. If the URL contained spaces, it would be quoted by subprocess,
1129+
# and if we did 'start %1', it would create a new cmd.exe window with the URL as title instead of
1130+
# actually launching the browser. Therefore, we must pass a dummy quoted first argument for start
1131+
# to interpret as the title. For this purpose, we use the empty string, which will be quoted
1132+
# as "". See #9253 for details.
1133+
return ['cmd', '/C', 'start', '']
11271134

11281135

11291136
def find_browser(name):

0 commit comments

Comments
 (0)