3 ms·
> to force software to support spaces in paths And yet the platform where it's hardest to support spaces in paths is... windows! On UNIX the process-creation
by bodyfour 13y ago
> to force software to support spaces in paths
And yet the platform where it's hardest to support spaces in paths is... windows!
On UNIX the process-creation API (execve) explicitly takes an array of arguments. There really aren't any special characters as far as the API is concerned (except \0): what you pass to execve will be the same as what the new process sees in main()
In windows, CreateProcessW() just is given a command line with space-separated argument names. Then the CRT in the new process will split that back up before main() is called. To be sure to get the arguments you want in main() you need to carefully quote the parameter you pass to CreateProcess using the exact rules that the CRT will use to unquote them -- in my experience this wasn't well documented, either.
Worse, since that splitting is the responsibility of the new process, programs can skip the CRT and do it themselves. If they don't follow exactly the same rules the CRT does things break if you try to send an argument with an escaped metacharacter.
- jfb 13y agoThe problem with paths with spaces on Unix is not the API, it's the shell.