Hello!

I have recently noticed that the Windows command line parsing routine of Cygwin 
programs does not
work correctly when an escaped quotation mark is included. This is relevant 
when launching a Cygwin-
based GCC through Windows CMake-generated Ninja files. We are passing 
preprocessor definitions
containing quotation marks to GCC and CMake wants to pass them 
backslash-escaped, but unquoted, on
the command line.

A test program I have written to inspect this issue:

#include <stdio.h>
int main(int argc, char** argv) {
  for (int i = 0; i < argc; ++i) puts(argv[i]);
}

Running it (via cmd.exe):

>echo.exe a b\"c\" d
echo
a
b\c" d

The first escape sequence is ignored, but the quote is read and causes the 
parser to switch to
quoted argument mode where it recognizes the remaining escaped quotes as it 
already should have done
in regular parsing mode. It then proceeds to eat the remaining command line as 
there aren't any
unescaped quotation marks, usually leading GCC to complain about no input files 
being given.

Running the Windows-native version of the program:

>echo-win32.exe a b\"c\" d
echo-win32.exe
a
b"c"
d

This should be the expected output. Is the way the escaped quotation mark is 
treated intended
behavior? I cannot really see how it would be, given that the parser is only 
used for command lines
stemming from being launched by Windows-native programs.

Best regards

Oliver Old

________________________________
LÖWEN ENTERTAINMENT GmbH • Saarlandstraße 240 • 55411 Bingen am Rhein • 
Geschäftsführung: Christian Arras (Vorsitzender), Oliver Bagus, Dr. Daniel 
Henzgen • Vorsitz im Aufsichtsrat: Uwe Christiansen • Amtsgericht Mainz • HRB 
23327 • USt.-IdNr. DE148266135 • WEEE-Reg.-Nr. DE 53361450 • Tel.: +49 6721 407 
0 • E-Mail: i...@loewen.de

-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

Reply via email to