Bug 19502 – windows command line arguments wrongly split

Status
NEW
Severity
major
Priority
P2
Component
druntime
Product
D
Version
D2
Platform
All
OS
Windows
Creation time
2018-12-18T18:15:21Z
Last change time
2024-12-07T13:39:06Z
Keywords
pull
Assigned to
No Owner
Creator
John Colvin
Moved to GitHub: dmd#17379 →

Comments

Comment #0 by john.loughran.colvin — 2018-12-18T18:15:21Z
Druntime currently uses CommandLineToArgvW to deal with the command line args on windows, which is a close but not exact match to how the C runtime on windows works. In the case where the command line looks like this: "C:\test\"\blah.exe Druntime using CommandLineToArgvW parses this as ["C:\\test\\", "\\blah.exe"] note the 2 !!! arguments. The c runtime does ["C:\test\\blah.exe"] The result is that programs that look at args might behave completely differently depending on exactly how the path to them is written.
Comment #1 by dlang-bot — 2020-02-04T06:33:16Z
@LimiQS created dlang/druntime pull request #2931 "Fix Issue 19502: Implement correct split behavior" fixing this issue: - Fix Issue 19502 - Implement correct split https://github.com/dlang/druntime/pull/2931
Comment #2 by r.sagitario — 2020-02-04T07:09:51Z
I don't see any difference in arguments for D or C++ (VC16). Both produce `C:\test"\blah.exe` for the example in the bug report. What OS/VC version are you seeing the difference with?
Comment #3 by dlang-bot — 2020-02-04T07:23:38Z
@LimiQS created dlang/druntime pull request #2932 "Fix Issue 19502: Implement correct split behavior" fixing this issue: - Fix Issue 19502: Implement correct split behavior https://github.com/dlang/druntime/pull/2932
Comment #4 by himeix — 2020-02-04T07:31:50Z
(In reply to Rainer Schuetze from comment #2) > I don't see any difference in arguments for D or C++ (VC16). Both produce > `C:\test"\blah.exe` for the example in the bug report. > > What OS/VC version are you seeing the difference with? I'm on Windows 10 x64 with VC 2019. In a test with the following codes: int main(string[] argv) { foreach(i; argv) writeln(i); return 0; } The cmd.exe raw displays: C:\Users\XXX>"C:\Users\XXX\source\repos\test\x64\Debug\"\test.exe C:\Users\XXX\source\repos\test\x64\Debug\ \test.exe I reproduced this issue.
Comment #5 by r.sagitario — 2020-02-04T08:16:09Z
Ah, it only applies to the program itself, not the additional arguments. Thanks for the clarification.
Comment #6 by robert.schadek — 2024-12-07T13:39:06Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17379 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB