This is the mail archive of the
mailing list for the Cygwin project.
RE: Formatting command line arguments when starting a Cygwin process from a native process
- From: David Allsopp <david at allsopps dot net>
- To: Aaron Digulla <digulla at hepe dot com>, "cygwin at cygwin dot com" <cygwin at cygwin dot com>
- Date: Mon, 9 May 2016 15:19:42 +0000
- Subject: RE: Formatting command line arguments when starting a Cygwin process from a native process
- Authentication-results: sourceware.org; auth=none
- References: <006301d1a834$6ccd1380$46673a80$ at cantab dot net> <5ba8-5730a580-3b-2319ce00 at 26574710>
Aaron Digulla wrote:
> Am Samstag, 07. Mai 2016 09:45 CEST, "David Allsopp" <firstname.lastname@example.org>
> > > Then all you need is a rudimentary quoting.
> > Yes, but the question still remains what that rudimentary quoting is -
> > I can see how to quote spaces which appear in elements of argv, but I
> > cannot see how to quote double quotes!
> This should help:
This provides documentation for how Microsoft implementations do it, not how Cygwin does it. The Cygwin DLL is responsible for determining how a Cygwin process gets argc and argv from GetCommandLineW.
> My line of thought is that Cygwin can't get anything which Windows can't
> send it. So the first step to solve this mess is to make sure the
> arguments which you send to CreateProcess() are correct.
> The next step would be to write a small C utility which dumps it's
> arguments, so you can properly debug all kinds of characters.
See later email, but IMHO the conversion is something Cygwin should have precisely documented, not determined by brittle experimentation.
> PS: I always point people to string list/array type methods to create
> processes which fix all the problems with spaces and odd characters
> (quotes, umlauts, etc). It seems that Windows doesn't have such a method
> to create processes. Which kind of makes sense; Windows is very, very
> mouse centered.
I fail to see the connection with mice! What Windows (NT) does have is a legacy where the decision on how to convert a command line to a list/array of arguments is determined per-process (and so not the responsibility of command line shells) vs Unix which puts the burden of converting a single command line to the array on the shell instead. Nominally, the Windows way is more flexible, though I don't think that flexibility is actually useful (especially if you look at the comments in the command line -> argv conversion in Microsoft's C Runtime library!).