News for hackers. Stuff that matters.
Re:I'm “still afraid to use spaces in file names” years old by dale_glass on Thursday November 11, 2021 @08:51AM (#29187795)
And that was a good idea, if only Microsoft also fixed the CreateProcess function, Windows would be somewhat sane in this regard. But somehow nobody seemed to think of it. Seriously, look at it:

https://docs.microsoft.com/en-us/windows/win32/api/processth...

The arguments are a single string. So you want to pass parameters with spaces in them? You've got to add quotes and stuff all of that into a single string. Instead of doing it in a more sane manner, like oh, the arguments to main().

Re:I'm “still afraid to use spaces in file names” years old by IiydAbITMvJkqKf on Thursday November 11, 2021 @08:58AM (#29187868)
The root cause is that argv isn't a first-class citizen like on linux, but an abstraction. The kernel only cares about a single string argument. If you use main instead of WinMain, the CRT will transform the single string into an argv for you.

Oh and cmd.exe uses a different escaping scheme than the CRT.

Re:I'm “still afraid to use spaces in file names” years old by dale_glass on Thursday November 11, 2021 @09:19AM (#29188069)
Microsoft is in full control of the Windows kernel, so they can make it care about whatever they want to, and one would think better argument passing would be a nice quality of life improvement. Less nonsense for developers to deal with, and less weird bugs on the platform.
Re:I'm “still afraid to use spaces in file names” years old by exciteabletom on Thursday November 11, 2021 @09:34AM (#29188205)
Sure, but MS values backwards compatibility a lot.

They aren't going to break existing API or bloat the kernel with a bunch of functions that do the same thing.

Re:I'm “still afraid to use spaces in file names” years old by Joker_vD on Thursday November 11, 2021 @10:15AM (#29188709)
They can either add a new API which almost nobody would use ― because everyone already learned to use the existing one and either reused or reimplemented the MSVCRT's logic so that most of the software parse the command lines the same way; or they can literally break every single program in existence by breaking the interface of CreateProcess ― which is just as likely as Linux breaking the interface of execve(2).

Giving CreateProcess a new flag so it would to correctly accept "path\\to\\my\\program.exe\0arg_1\0second argument\0argument with literal \" symbol" (with an implicit \0 terminating it) as lpszCmdLine is an easy part; the hard part would be forcing everyone to switch to using it.

Also, I'm pretty certain this processing happens in the user space, and Win32 API is already bloated beyond any belief.

Re:I'm “still afraid to use spaces in file names” years old by naikrovek on Thursday November 11, 2021 @09:17PM (#29195647)
maintaining backwards compatibility means maintaining silly decisions, and Microsoft does both.