in reply to Re^7: quoting issue with system command (Win32)
in thread quoting issue with system command

The de-facto standard is the way that Microsoft's compiler's RTL start-up code does it. I've just copied that function directly when doing my own parsing.

In stdargv.c,

A quoted program name is handled here. The handling is much simpler than for other arguments. Basically, whatever lies between the leading double-quote and next one, or a terminal null character is simply accepted. Fancier handling is not required because the program name must be a legal NTFS/HPFS file name.
Note that the double-quote characters are not copied, nor do they contribute to numchars.
and then
Rules: 2N backslashes + " ==> N backslashes and begin/end quote
2N+1 backslashes + " ==> N backslashes + literal "
N backslashes ==> N backslashes
This means that if the EXE file name does have a 0x22 (QUOTATION MARK) in it, it won't parse out the argv/argc properly. Contrary to the comment, you can have a file by this name, and there are other file systems besides NTFS. Not using [<>:"/\|?*] in a file name on any filesystem is a Win32 convention, not a file system limitation.

  • Comment on Re^8: quoting issue with system command (Win32)