From 38a3c9bf256aec1f9b06517e6ec3945d4b8bbdc9 Mon Sep 17 00:00:00 2001 From: Siddhanth Gupta Date: Wed, 4 Nov 2026 01:54:23 +0530 Subject: [PATCH] fix(mkconcore): launch quoted tool paths in Windows run/debug scripts Quoting tool executables broke two Windows launch lines: - start takes the first quoted argument as the window title, so `start /B /D "CZ" "python" "x.py"` never ran python. Pass an empty title. - cmd /K strips the outer quotes of `"python" "x.py"`. Wrap the payload in one more pair of quotes. --- mkconcore.py | 12 ++++++------ tests/test_cli.py | 9 +++++++++ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/mkconcore.py b/mkconcore.py index a1f44ef..9991cd7 100644 --- a/mkconcore.py +++ b/mkconcore.py @@ -1245,8 +1245,8 @@ def cleanup_script_files(): q_source = f'"{sourcecode}"' if langext=="py": - frun.write('start /B /D '+q_container+" "+PYTHONWIN+" "+q_source+" >"+q_container+"\\concoreout.txt\n") - fdebug.write('start /D '+q_container+" cmd /K "+PYTHONWIN+" "+q_source+"\n") + frun.write('start "" /B /D '+q_container+" "+PYTHONWIN+" "+q_source+" >"+q_container+"\\concoreout.txt\n") + fdebug.write('start /D '+q_container+' cmd /K "'+PYTHONWIN+" "+q_source+'"\n') elif langext=="cpp": #6/25/21 frun.write('cd '+q_container+'\n') frun.write(CPPWIN+' '+q_source+'\n') @@ -1281,11 +1281,11 @@ def cleanup_script_files(): elif langext=="m": #3/23/21 # Use q_source in Windows commands to ensure quoting consistency if M_IS_OCTAVE: - frun.write('start /B /D '+q_container+" "+OCTAVEWIN+' -qf --eval "run('+q_source+')"'+" >"+q_container+"\\concoreout.txt\n") - fdebug.write('start /D '+q_container+" cmd /K " +OCTAVEWIN+' -qf --eval "run('+q_source+')"'+"\n") + frun.write('start "" /B /D '+q_container+" "+OCTAVEWIN+' -qf --eval "run('+q_source+')"'+" >"+q_container+"\\concoreout.txt\n") + fdebug.write('start /D '+q_container+' cmd /K "' +OCTAVEWIN+' -qf --eval "run('+q_source+')""'+"\n") else: # 4/2/21 - frun.write('start /B /D '+q_container+" "+MATLABWIN+' -batch "run('+q_source+')"'+" >"+q_container+"\\concoreout.txt\n") - fdebug.write('start /D '+q_container+" cmd /K " +MATLABWIN+' -batch "run('+q_source+')"'+"\n") + frun.write('start "" /B /D '+q_container+" "+MATLABWIN+' -batch "run('+q_source+')"'+" >"+q_container+"\\concoreout.txt\n") + fdebug.write('start /D '+q_container+' cmd /K "' +MATLABWIN+' -batch "run('+q_source+')""'+"\n") else: #use shlex.quote for POSIX systems safe_container = shlex.quote(containername) diff --git a/tests/test_cli.py b/tests/test_cli.py index b95c60d..bf52d15 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -406,6 +406,15 @@ def test_build_command_quotes_windows_tool_path_with_spaces(self): '"C:\\Program Files\\Python313\\python.exe" "script.py"', run_script, ) + self.assertIn( + 'start "" /B /D "N1" "C:\\Program Files\\Python313\\python.exe" "script.py"', + run_script, + ) + debug_script = Path("out/debug.bat").read_text() + self.assertIn( + 'cmd /K ""C:\\Program Files\\Python313\\python.exe" "script.py""', + debug_script, + ) def test_build_command_nested_output_path(self): with self.runner.isolated_filesystem(temp_dir=self.temp_dir):