play.ps1: gta6rt gets the folders as they were typed (PLAY-PS1-ARG-QUOTING) #3280
No reviewers
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
No due date set.
Reference
leonida/mandy!3280
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/play-ps1-arg-quoting"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Pull request successfully merged and closed
Claim: https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7361352199 (PLAY-PS1-ARG-QUOTING)
What and why
scripts/play.ps1startsgta6rt.exewithStart-Process, which quotes nothing, so it quoted--run,--game-dir,--overlayand--traceby hand (""$Game""). gta6rt reads its arguments throughwmain's argv (runtime/src/main.cpp), that is, byCommandLineToArgvW's rules, where a backslash in front of a quote escapes it. A folder typed with its last backslash (-Game D:\pkg\) therefore reached gta6rt asD:\pkg" --overlay ...: the folder and the arguments after it were merged. This is the same defect #3257 fixes ingame-gate.ps1and for the button-prompt tool.What changed
scripts/play.ps1:ConvertTo-Argumentquotes each value by those rules. The backslashes in front of a quote or of the closing quote are doubled (\z, not$). gta6rt makes both folders absolute and joins with/, so a trailing backslash it now receives intact is harmless.tests/test_play_ps1_args.pycompiles a stand-ingta6rt.exewithAdd-Typethat writes down its argv. It runsplay.ps1with folders that have spaces and are typed with their last backslash, and checks the eight arguments gta6rt receives.Verification (Windows 11, Windows PowerShell 5.1, Python 3.11; no game files, no GPU needed)
.ps1change reverted, the test fails (--game-dirarrives as...\my game" --overlay ...). With it, the test passes.python -I scripts/check_no_game_data.pyon both files: exit 0. The.ps1stays CRLF and ASCII; the test is LF and ASCII.AI assistance
AI-assisted: written with Claude Code (Claude Opus 5.5). It was reviewed by a separate read-only reviewer agent (Claude Opus 5.5), which confirmed that gta6rt parses through
wmainargv by the same rules as the stand-in, that a trailing backslash is harmless to its path handling, and that nothing else builds gta6rt's arguments this way. It found nothing blocking; I applied its suggestion to let the test's temporary folder clean up even if the compiled stand-in is still held open.VERIFY-3280 — Windows nativo: el control quita el doblado de la barra final y el test muerde
Un commit, dos ficheros:
En el head (
fff47a330):Control (sintético): quité el segundo
-replace, el que dobla las barras finales —y el test falla:
Muerde, y muerde el caso que el test nombra:
test_folders_ending_in_a_backslash_reach_the_runtime_whole— una carpetaD:\pkg\que llega al runtime partida por la mitad, que es justo lo que el comentario del cambio dice: "backslashes in front of a quote or of the closing quote are doubled, else-Game D:\pkg\would escape the closing quote and take the next argument with it."Y por qué la función está escrita así, que es lo que quiero verificar en el fondo: no es «escapar comillas», es la regla de
CommandLineToArgvW— las barras delante de una comilla o delante de la comilla de cierre se doblan, y sólo ésas. Doblar todas romperíaC:\Games; no doblar la última se come el argumento siguiente. La expresión hace exactamente las dos cosas y el test comprueba las dos direcciones (args[:6]con las rutas enteras ylen(args) == 8sin argumentos de más).Lo que no probé
play.ps1y compara elargvque se construye, que es el punto, pero no el proceso hijo real de gta6rt.Written with an AI assistant.
Windows native verification (
red -> green) -- PASS on headfff47a330(merged cleanly viagit merge --no-ffontomaind9b618f10).Checks (Windows 10 x64, Python 3.12, PowerShell 5.1)
python -I scripts/check_no_game_data.py-> PASSpython -I tests/test_play_ps1_args.py -v-> Ran 1 test in 0.530s / OKscripts/play.ps1tomaind9b618f10, keeping the PR's tests):tests/test_play_ps1_args.py-> Ran 1 test in 0.520s / FAILED (failures=1) (exit1)AI-assisted: yes (Antigravity -- Gemini 4 Neon).
tested: the new test passes on this machine, and the folder with a space in it is exactly the case here. Machine: Windows 11, NVIDIA GeForce RTX 5080, driver 621.47, hardware-accelerated GPU scheduling on, page file 49,152 MB, tree at
e5c777734(threed3d12/README.mdcommits on maind9b618f10).python -I tests/test_play_ps1_args.py->Ran 1 test in 0.749s,OK, rc 0.node --test tests/test_*.cjs-> 113 tests, 0 fail. Headfff47a330.Every path on this box has a space in it, so the quoting is not a corner case here: the game is at
F:\GTA 6\GTA6.Xbox.v1.0.2.1-CYBERLEEKand the data folder atF:\GTA 6\Leonida, and the same folders go toplay-d3d12.ps1for the D3D12 layer, where they already arrive whole. The Vulkan runtime is not built on this machine (runtime\build-vk\RelWithDebInfo\gta6rt.exeabsent), so the script's own test is the evidence, and the argument list is built atscripts/play.ps1:50with theCommandLineToArgvWquoting the comment names.