4 ms·
Indeed. Splitting, quotes and globs are all handled by the application rather than the shell. Furthermore, you don't just have the two categories of "programs
by Arnavion 5y ago
Indeed. Splitting, quotes and globs are all handled by the application rather than the shell.
Furthermore, you don't just have the two categories of "programs that use libc" and "programs that wing it", but also the third category of "programs that use shell32". Windows ships with two cmdline->argv implementations - one in MSVCRT and the other in shell32. Both are first-party but don't split args the same in all cases.
- silon42 5y agoThere is a great example of "start" command that has a very uncool feature when using double quotes.
- ygra 5y agoThat's a shell built-in, though. So how command-line arguments are handled by processes and the OS doesn't really apply here.
- CyberShadow 5y agoWhat is an example of a command line string that is split differently by Shell32 and MSVCRT? In D, we use CommandLineToArgvW. I'm guessing it's related to Unicode?
- formerly_proven 5y agoMSDN has this blurb with sounds rather... weird to me: > CommandLineToArgvW has a special interpretation of backslash characters when they are followed by a quotation mark character ("). This interpretation assumes that any preceding argument is a valid file system path, or else it may behave unpredictably.
- Arnavion 5y agohttps://github.com/rust-lang/rust/issues/44650 https://github.com/rust-lang/rust/issues/44650 (Nothing to do with unicode. I haven't got a Windows machine to test, but I assume WinMain will behave the same as main wrt quotes and spaces.) (Note that Rust doesn't use CLTAW any more; it switched to "winging it" ie its own implementation. Among other things, this allowed it to drop the dependency on shell32, which is useful for running compiled binaries in nanoserver containers.)