Process argument passing problems
Sat Jun 22 07:09:00 GMT 2019

On Fri, 2019-06-21 at 22:15 +0200, Hans-Bernhard Bröker wrote:
> Am 21.06.2019 um 17:19 schrieb
> > Hey everyone,
> > 
> > I have to following problem (using cmd.exe):
> > 
> > C:\cygwin64\home\xy>C:\cygwin64\bin\echo.exe -DFOO=\"BAR\" -DBAR=\"FOO\"
> > 
> > I would have expected:
> > 
> Expecting cmd.exe to parse command lines in anything resembling a sane
> way is, unfortunately, an exercise in futility.
> Microsoft allowed blanks in filenames with hardly any regard for the
> concepts of command lines and their parsing.  We're still fighting with
> the repercussions now, 25 years later.

I'm actually using ProcessCreate() and calling cygwin gcc. The echo.exe example
seemed to show the exact same problem which is why I thought it might be easier
to reproduce for others.

> > Context: I'm executing various cygwin programs through (native) Python and
> > passing C macros to gcc like 'gcc -DFOO=\"BAR\"' fails because of this.
> Are you sure Python even goes through cmd.exe to pass those command
> lines?  If it doesn't, figuring out what cmd.exe does may be even less
> fruitful than it already is.

Not, it doesn't use cmd.exe. It uses subprocess.list2cmdline to convert the
argument list to something suitable for ProcessCreate() and then calls

>>> subprocess.list2cmdline(['-DFOO="BAR"'])

> > More background:
> Please note that that's about MSYS2, which, while closely related to
> Cygwin, is not really the topic of this mailing list.

Feel free to ignore it if doesn't help. The bug shows how I came to the
conclusion that it might be a cygwin bug, which made me post here.


Problem reports:
Unsubscribe info:

More information about the Cygwin mailing list