DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 572HT7Y7420289 Authentication-Results: delorie.com; dmarc=pass (p=none dis=none) header.from=cygwin.com Authentication-Results: delorie.com; spf=pass smtp.mailfrom=cygwin.com DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 572HT7Y7420289 Authentication-Results: delorie.com; dkim=pass (1024-bit key, unprotected) header.d=cygwin.com header.i=@cygwin.com header.a=rsa-sha256 header.s=default header.b=xdcPWMVt X-Recipient: archive-cygwin AT delorie DOT com DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EE2493858C54 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; s=default; t=1754131863; bh=r6irZssU/YhIRQKvioQCIARGY6h/Zci/wuQkls11BLc=; h=Date:To:Subject:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=xdcPWMVtVLXHgjLq6bFCOV7Gp+taGLogn9Xi2yZMd6OUzYGKjNJdndXGwAgfOsVEx 5uFM9kJNUqr8kmjz6Zq4Sow4AXjlIuaYSqK6NJbLQoYl/Zi0ZIMsIzbZvkzMlCB2On iuCCWSHb13eW7x20SHW4UmnCF0n4PfzbDI8OtL4E= X-Original-To: cygwin AT cygwin DOT com Delivered-To: cygwin AT cygwin DOT com DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3F7B53858D1E ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 3F7B53858D1E ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1754131804; cv=none; b=SdAKfONSV1pAyoXU4kZhrt1GYsCNn7pjcHEy4qwD2okdQfnraLw+lwiO2XgeHsno1jIPhqw2t7ikuGmkbTwtVaXVdmwkN3aX7YauZtul0BHoj3fam42VnAHTxBzOqwRnquRZ2JblyomKBcbGpHcb6k2SCFF5RCVcIp0vYoTDKTc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1754131804; c=relaxed/simple; bh=iboPqlbZDB9+97eQkcEQCaSXhhHVBSQc3WC98qx7Pjs=; h=DKIM-Signature:Date:From:Message-ID:To:Subject:MIME-Version; b=PXPOZg0JdKUfclHMYFh2UBxoSjA0Pgs1gpDiikYBC4s+oaW5HO6GGhZx4TD/VS0fVM9Tj6h54QYgkd5bh8igpU+uJaLY64yEbOm9eOOgUq6gQGn6Uh1tMs9xTBRpDue3qAOztNd8njzoLzAVKr3fDpTJEczAYEfqFgIZUz9TLxs= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3F7B53858D1E X-Yandex-Fwd: 1 Date: Sat, 2 Aug 2025 13:40:26 +0300 X-Mailer: The Bat! (v9.3.4) Professional Message-ID: <1132382880.20250802134026@yandex.ru> To: "Old, Oliver" , cygwin AT cygwin DOT com Subject: Re: Incorrect command line handling when launching Cygwin program from Windows In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: cygwin AT cygwin DOT com X-Mailman-Version: 2.1.30 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Andrey Repin via Cygwin Reply-To: cygwin AT cygwin DOT com Cc: Andrey Repin Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com Sender: "Cygwin" Greetings, Old, Oliver! > 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 > 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 When you run a program using cmd.exe you are using CMD's parsing semantics. (Or, rather, the cmd parses the string first and then sends the results to an executed command.) If you want to escape it (at least partially), use cmd's /S switch and wrap your ENTIRE command in quotation marks. > 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. Wrong question. -- With best regards, Andrey Repin Saturday, August 2, 2025 13:36:48 Sorry for my terrible english... -- 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