From 1c5d075af0929665a6aa19b7cbd50216c7fe166e Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Wed, 13 Dec 2023 11:50:12 -0800 Subject: [PATCH] Fix for chatty bat files when path contains spaces I have no idea what causes this issue but unless we code the path passed to `@if exist` then the commands within are echoed. This only happens when the path contains spaces, and only for the to commands within the `@if exist`. The endless mystery of cmd.exe. Fixes: #20913 --- .circleci/config.yml | 1 + bootstrap.bat | 2 +- em++.bat | 2 +- em-config.bat | 2 +- emar.bat | 2 +- embuilder.bat | 2 +- emcc.bat | 2 +- emcmake.bat | 2 +- emconfigure.bat | 2 +- emdump.bat | 2 +- emdwp.bat | 2 +- emmake.bat | 2 +- emnm.bat | 2 +- emprofile.bat | 2 +- emranlib.bat | 2 +- emrun.bat | 2 +- emscons.bat | 2 +- emsize.bat | 2 +- emstrip.bat | 2 +- emsymbolizer.bat | 2 +- system/bin/sdl-config.bat | 2 +- system/bin/sdl2-config.bat | 2 +- test/runner.bat | 2 +- test/test_other.py | 7 +++++++ tools/file_packager.bat | 2 +- tools/maint/run_python.bat | 2 +- tools/maint/run_python_compiler.bat | 2 +- tools/webidl_binder.bat | 2 +- 28 files changed, 34 insertions(+), 26 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 970203afbd6a6..06e721112a149 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -828,6 +828,7 @@ jobs: # windows and mac do not have separate build and test jobs, as they only run # a limited set of tests; it is simpler and faster to do it all in one job. test-windows: + working_directory: "~/path with spaces" executor: name: win/vs2019 shell: bash.exe -eo pipefail diff --git a/bootstrap.bat b/bootstrap.bat index b574e98809e73..83edd646f7918 100644 --- a/bootstrap.bat +++ b/bootstrap.bat @@ -22,7 +22,7 @@ :: script is invoked via enclosing the invocation in quotes via PATH lookup, then %~f0 and :: %~dp0 expansions will not work. :: So first try if %~dp0 might work, and if not, manually look up this script from PATH. -@if exist %~f0 ( +@if exist "%~f0" ( set MYDIR=%~dp0 goto FOUND_MYDIR ) diff --git a/em++.bat b/em++.bat index 86ae9bb841f35..68026fe148de5 100644 --- a/em++.bat +++ b/em++.bat @@ -22,7 +22,7 @@ :: script is invoked via enclosing the invocation in quotes via PATH lookup, then %~f0 and :: %~dp0 expansions will not work. :: So first try if %~dp0 might work, and if not, manually look up this script from PATH. -@if exist %~f0 ( +@if exist "%~f0" ( set MYDIR=%~dp0 goto FOUND_MYDIR ) diff --git a/em-config.bat b/em-config.bat index b574e98809e73..83edd646f7918 100644 --- a/em-config.bat +++ b/em-config.bat @@ -22,7 +22,7 @@ :: script is invoked via enclosing the invocation in quotes via PATH lookup, then %~f0 and :: %~dp0 expansions will not work. :: So first try if %~dp0 might work, and if not, manually look up this script from PATH. -@if exist %~f0 ( +@if exist "%~f0" ( set MYDIR=%~dp0 goto FOUND_MYDIR ) diff --git a/emar.bat b/emar.bat index b574e98809e73..83edd646f7918 100644 --- a/emar.bat +++ b/emar.bat @@ -22,7 +22,7 @@ :: script is invoked via enclosing the invocation in quotes via PATH lookup, then %~f0 and :: %~dp0 expansions will not work. :: So first try if %~dp0 might work, and if not, manually look up this script from PATH. -@if exist %~f0 ( +@if exist "%~f0" ( set MYDIR=%~dp0 goto FOUND_MYDIR ) diff --git a/embuilder.bat b/embuilder.bat index b574e98809e73..83edd646f7918 100644 --- a/embuilder.bat +++ b/embuilder.bat @@ -22,7 +22,7 @@ :: script is invoked via enclosing the invocation in quotes via PATH lookup, then %~f0 and :: %~dp0 expansions will not work. :: So first try if %~dp0 might work, and if not, manually look up this script from PATH. -@if exist %~f0 ( +@if exist "%~f0" ( set MYDIR=%~dp0 goto FOUND_MYDIR ) diff --git a/emcc.bat b/emcc.bat index 86ae9bb841f35..68026fe148de5 100644 --- a/emcc.bat +++ b/emcc.bat @@ -22,7 +22,7 @@ :: script is invoked via enclosing the invocation in quotes via PATH lookup, then %~f0 and :: %~dp0 expansions will not work. :: So first try if %~dp0 might work, and if not, manually look up this script from PATH. -@if exist %~f0 ( +@if exist "%~f0" ( set MYDIR=%~dp0 goto FOUND_MYDIR ) diff --git a/emcmake.bat b/emcmake.bat index b574e98809e73..83edd646f7918 100644 --- a/emcmake.bat +++ b/emcmake.bat @@ -22,7 +22,7 @@ :: script is invoked via enclosing the invocation in quotes via PATH lookup, then %~f0 and :: %~dp0 expansions will not work. :: So first try if %~dp0 might work, and if not, manually look up this script from PATH. -@if exist %~f0 ( +@if exist "%~f0" ( set MYDIR=%~dp0 goto FOUND_MYDIR ) diff --git a/emconfigure.bat b/emconfigure.bat index b574e98809e73..83edd646f7918 100644 --- a/emconfigure.bat +++ b/emconfigure.bat @@ -22,7 +22,7 @@ :: script is invoked via enclosing the invocation in quotes via PATH lookup, then %~f0 and :: %~dp0 expansions will not work. :: So first try if %~dp0 might work, and if not, manually look up this script from PATH. -@if exist %~f0 ( +@if exist "%~f0" ( set MYDIR=%~dp0 goto FOUND_MYDIR ) diff --git a/emdump.bat b/emdump.bat index f9fb29c0fbf08..0f19bc7842dc2 100644 --- a/emdump.bat +++ b/emdump.bat @@ -22,7 +22,7 @@ :: script is invoked via enclosing the invocation in quotes via PATH lookup, then %~f0 and :: %~dp0 expansions will not work. :: So first try if %~dp0 might work, and if not, manually look up this script from PATH. -@if exist %~f0 ( +@if exist "%~f0" ( set MYDIR=%~dp0 goto FOUND_MYDIR ) diff --git a/emdwp.bat b/emdwp.bat index 23d1e45dfea9f..5e4d8658ab9ae 100644 --- a/emdwp.bat +++ b/emdwp.bat @@ -22,7 +22,7 @@ :: script is invoked via enclosing the invocation in quotes via PATH lookup, then %~f0 and :: %~dp0 expansions will not work. :: So first try if %~dp0 might work, and if not, manually look up this script from PATH. -@if exist %~f0 ( +@if exist "%~f0" ( set MYDIR=%~dp0 goto FOUND_MYDIR ) diff --git a/emmake.bat b/emmake.bat index b574e98809e73..83edd646f7918 100644 --- a/emmake.bat +++ b/emmake.bat @@ -22,7 +22,7 @@ :: script is invoked via enclosing the invocation in quotes via PATH lookup, then %~f0 and :: %~dp0 expansions will not work. :: So first try if %~dp0 might work, and if not, manually look up this script from PATH. -@if exist %~f0 ( +@if exist "%~f0" ( set MYDIR=%~dp0 goto FOUND_MYDIR ) diff --git a/emnm.bat b/emnm.bat index e3b5824748a65..80c49452b38f9 100644 --- a/emnm.bat +++ b/emnm.bat @@ -22,7 +22,7 @@ :: script is invoked via enclosing the invocation in quotes via PATH lookup, then %~f0 and :: %~dp0 expansions will not work. :: So first try if %~dp0 might work, and if not, manually look up this script from PATH. -@if exist %~f0 ( +@if exist "%~f0" ( set MYDIR=%~dp0 goto FOUND_MYDIR ) diff --git a/emprofile.bat b/emprofile.bat index c28cf0878c659..5f5be5c32710c 100644 --- a/emprofile.bat +++ b/emprofile.bat @@ -22,7 +22,7 @@ :: script is invoked via enclosing the invocation in quotes via PATH lookup, then %~f0 and :: %~dp0 expansions will not work. :: So first try if %~dp0 might work, and if not, manually look up this script from PATH. -@if exist %~f0 ( +@if exist "%~f0" ( set MYDIR=%~dp0 goto FOUND_MYDIR ) diff --git a/emranlib.bat b/emranlib.bat index b574e98809e73..83edd646f7918 100644 --- a/emranlib.bat +++ b/emranlib.bat @@ -22,7 +22,7 @@ :: script is invoked via enclosing the invocation in quotes via PATH lookup, then %~f0 and :: %~dp0 expansions will not work. :: So first try if %~dp0 might work, and if not, manually look up this script from PATH. -@if exist %~f0 ( +@if exist "%~f0" ( set MYDIR=%~dp0 goto FOUND_MYDIR ) diff --git a/emrun.bat b/emrun.bat index b574e98809e73..83edd646f7918 100644 --- a/emrun.bat +++ b/emrun.bat @@ -22,7 +22,7 @@ :: script is invoked via enclosing the invocation in quotes via PATH lookup, then %~f0 and :: %~dp0 expansions will not work. :: So first try if %~dp0 might work, and if not, manually look up this script from PATH. -@if exist %~f0 ( +@if exist "%~f0" ( set MYDIR=%~dp0 goto FOUND_MYDIR ) diff --git a/emscons.bat b/emscons.bat index b574e98809e73..83edd646f7918 100644 --- a/emscons.bat +++ b/emscons.bat @@ -22,7 +22,7 @@ :: script is invoked via enclosing the invocation in quotes via PATH lookup, then %~f0 and :: %~dp0 expansions will not work. :: So first try if %~dp0 might work, and if not, manually look up this script from PATH. -@if exist %~f0 ( +@if exist "%~f0" ( set MYDIR=%~dp0 goto FOUND_MYDIR ) diff --git a/emsize.bat b/emsize.bat index b574e98809e73..83edd646f7918 100644 --- a/emsize.bat +++ b/emsize.bat @@ -22,7 +22,7 @@ :: script is invoked via enclosing the invocation in quotes via PATH lookup, then %~f0 and :: %~dp0 expansions will not work. :: So first try if %~dp0 might work, and if not, manually look up this script from PATH. -@if exist %~f0 ( +@if exist "%~f0" ( set MYDIR=%~dp0 goto FOUND_MYDIR ) diff --git a/emstrip.bat b/emstrip.bat index b574e98809e73..83edd646f7918 100644 --- a/emstrip.bat +++ b/emstrip.bat @@ -22,7 +22,7 @@ :: script is invoked via enclosing the invocation in quotes via PATH lookup, then %~f0 and :: %~dp0 expansions will not work. :: So first try if %~dp0 might work, and if not, manually look up this script from PATH. -@if exist %~f0 ( +@if exist "%~f0" ( set MYDIR=%~dp0 goto FOUND_MYDIR ) diff --git a/emsymbolizer.bat b/emsymbolizer.bat index b574e98809e73..83edd646f7918 100644 --- a/emsymbolizer.bat +++ b/emsymbolizer.bat @@ -22,7 +22,7 @@ :: script is invoked via enclosing the invocation in quotes via PATH lookup, then %~f0 and :: %~dp0 expansions will not work. :: So first try if %~dp0 might work, and if not, manually look up this script from PATH. -@if exist %~f0 ( +@if exist "%~f0" ( set MYDIR=%~dp0 goto FOUND_MYDIR ) diff --git a/system/bin/sdl-config.bat b/system/bin/sdl-config.bat index b574e98809e73..83edd646f7918 100644 --- a/system/bin/sdl-config.bat +++ b/system/bin/sdl-config.bat @@ -22,7 +22,7 @@ :: script is invoked via enclosing the invocation in quotes via PATH lookup, then %~f0 and :: %~dp0 expansions will not work. :: So first try if %~dp0 might work, and if not, manually look up this script from PATH. -@if exist %~f0 ( +@if exist "%~f0" ( set MYDIR=%~dp0 goto FOUND_MYDIR ) diff --git a/system/bin/sdl2-config.bat b/system/bin/sdl2-config.bat index b574e98809e73..83edd646f7918 100644 --- a/system/bin/sdl2-config.bat +++ b/system/bin/sdl2-config.bat @@ -22,7 +22,7 @@ :: script is invoked via enclosing the invocation in quotes via PATH lookup, then %~f0 and :: %~dp0 expansions will not work. :: So first try if %~dp0 might work, and if not, manually look up this script from PATH. -@if exist %~f0 ( +@if exist "%~f0" ( set MYDIR=%~dp0 goto FOUND_MYDIR ) diff --git a/test/runner.bat b/test/runner.bat index b574e98809e73..83edd646f7918 100644 --- a/test/runner.bat +++ b/test/runner.bat @@ -22,7 +22,7 @@ :: script is invoked via enclosing the invocation in quotes via PATH lookup, then %~f0 and :: %~dp0 expansions will not work. :: So first try if %~dp0 might work, and if not, manually look up this script from PATH. -@if exist %~f0 ( +@if exist "%~f0" ( set MYDIR=%~dp0 goto FOUND_MYDIR ) diff --git a/test/test_other.py b/test/test_other.py index a15aedb1f12b9..67c5185f958ca 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -3269,6 +3269,7 @@ def test_file_packager_depfile(self): self.run_process([FILE_PACKAGER, 'test.data', '--js-output=test.js', '--depfile=test.data.d', '--from-emcc', '--preload', '.']) output = read_file('test.data.d') file_packager = utils.normalize_path(shared.replace_suffix(FILE_PACKAGER, '.py')) + file_packager = file_packager.replace(' ', '\\ ') lines = output.splitlines() split = lines.index(': \\') before, after = set(lines[:split]), set(lines[split + 1:]) @@ -14333,3 +14334,9 @@ def test_embind_negative_enum_values(self): expected = '-1\n0\n1\n' self.do_run(src, expected_output=expected, emcc_args=['-lembind', '-sALLOW_MEMORY_GROWTH', '-sMAXIMUM_MEMORY=4GB']) + + @crossplatform + def test_no_extra_output(self): + self.run_process([EMCC, '-c', test_file('hello_world.c')]) + output = self.run_process([EMCC, '-c', test_file('hello_world.c')], stdout=PIPE, stderr=STDOUT).stdout + self.assertEqual(output, '') diff --git a/tools/file_packager.bat b/tools/file_packager.bat index b574e98809e73..83edd646f7918 100644 --- a/tools/file_packager.bat +++ b/tools/file_packager.bat @@ -22,7 +22,7 @@ :: script is invoked via enclosing the invocation in quotes via PATH lookup, then %~f0 and :: %~dp0 expansions will not work. :: So first try if %~dp0 might work, and if not, manually look up this script from PATH. -@if exist %~f0 ( +@if exist "%~f0" ( set MYDIR=%~dp0 goto FOUND_MYDIR ) diff --git a/tools/maint/run_python.bat b/tools/maint/run_python.bat index b574e98809e73..83edd646f7918 100644 --- a/tools/maint/run_python.bat +++ b/tools/maint/run_python.bat @@ -22,7 +22,7 @@ :: script is invoked via enclosing the invocation in quotes via PATH lookup, then %~f0 and :: %~dp0 expansions will not work. :: So first try if %~dp0 might work, and if not, manually look up this script from PATH. -@if exist %~f0 ( +@if exist "%~f0" ( set MYDIR=%~dp0 goto FOUND_MYDIR ) diff --git a/tools/maint/run_python_compiler.bat b/tools/maint/run_python_compiler.bat index 86ae9bb841f35..68026fe148de5 100644 --- a/tools/maint/run_python_compiler.bat +++ b/tools/maint/run_python_compiler.bat @@ -22,7 +22,7 @@ :: script is invoked via enclosing the invocation in quotes via PATH lookup, then %~f0 and :: %~dp0 expansions will not work. :: So first try if %~dp0 might work, and if not, manually look up this script from PATH. -@if exist %~f0 ( +@if exist "%~f0" ( set MYDIR=%~dp0 goto FOUND_MYDIR ) diff --git a/tools/webidl_binder.bat b/tools/webidl_binder.bat index b574e98809e73..83edd646f7918 100644 --- a/tools/webidl_binder.bat +++ b/tools/webidl_binder.bat @@ -22,7 +22,7 @@ :: script is invoked via enclosing the invocation in quotes via PATH lookup, then %~f0 and :: %~dp0 expansions will not work. :: So first try if %~dp0 might work, and if not, manually look up this script from PATH. -@if exist %~f0 ( +@if exist "%~f0" ( set MYDIR=%~dp0 goto FOUND_MYDIR )