X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:references :in-reply-to:content-type:content-transfer-encoding :mime-version; q=dns; s=default; b=Sk9ITY9Ml6NerZKS/C+5jp8MapECX bE+r+3+VSWRgck0WOIf6ExTXY17wheysZJXD98VGwRPOto5hW95ytTfUVmGy/ICT QRq70LAz803bWQhbWbTksD2WKiSQIXExRl0KI7HRbUEA1IFWXhH03pwaDONHo7cQ Op1aV1/VWaYAqc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:references :in-reply-to:content-type:content-transfer-encoding :mime-version; s=default; bh=SUKdcNA8Af3698ixm/oAuHZerCA=; b=b5X FebUwkvHcSjvYWr3BCrQ1nAXRpbI/Poi60rm8YxJja3RSNO47+W/57ERaNkKwXyP 9TX6DoAMLNM2Qgaff7Z11a1VXMNhi4DGHi/YW0UmbRPv5XImcdanL167FZ9wMyv7 INJ27fGvwZGCe+/P6FudIaKxcrYwNkjxCYJcasaU= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.1 required=5.0 tests=BAYES_50,MIME_BASE64_BLANKS,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=H*r:FAIL, imho, IMHO, H*F:U*david X-HELO: outmail149095.authsmtp.com From: David Allsopp To: Aaron Digulla , "cygwin AT cygwin DOT com" Subject: RE: Formatting command line arguments when starting a Cygwin process from a native process Date: Mon, 9 May 2016 15:19:42 +0000 Message-ID: References: <006301d1a834$6ccd1380$46673a80$@cantab.net> <5ba8-5730a580-3b-2319ce00 AT 26574710> In-Reply-To: <5ba8-5730a580-3b-2319ce00@26574710> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 X-Server-Quench: 75b5a25f-15f9-11e6-829e-00151795d556 X-AuthReport-Spam: If SPAM / abuse - report it at: http://www.authsmtp.com/abuse X-AuthRoute: OCd1ZAARAlZZRRob BgsNCCtbTh09PVtK DAMVKBZePFsRUQkR aAdMdgsUFVQNAgsB AmAbWlJeUVR7XWc7 aQtScwRdZ1RMXgd0 UUlNXVBXCwQmRBgI cGRHI2BycQBCen8+ bUVqWD5cWRZ/JER4 FFNVEDsPeGZhPWYC WEJRIh5UcAJPfxhM bwR6UXVDAxANdgw/ BQo6IywwOzoXIyNQ RwgLIRoWQEAGVjcm SA0HEDMzBgUaRyg1 Zwc6I0QAHUAeekx6 GkouRlMeUVdaEhdZ FExWG2dXPV4EDyNj CwpGXFATWCVHRixR GQZA X-Authentic-SMTP: 61633634383431.1037:706 X-AuthFastPath: 0 (Was 255) X-AuthSMTP-Origin: 213.105.212.114/25 X-AuthVirus-Status: No virus detected - but ensure you scan with your own anti-virus system. Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by delorie.com id u49FKA58024313 Aaron Digulla wrote: > > Am Samstag, 07. Mai 2016 09:45 CEST, "David Allsopp" > schrieb: > > > > > Then all you need is a rudimentary quoting. > > > > Yes, but the question still remains what that rudimentary quoting is - > i.e. > > 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: > https://blogs.msdn.microsoft.com/twistylittlepassagesallalike/2011/04/23/e > veryone-quotes-command-line-arguments-the-wrong-way/ 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!). David