From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 89102 invoked by alias); 6 May 2016 14:35:24 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 89081 invoked by uid 89); 6 May 2016 14:35:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=4.0 required=5.0 tests=AWL,BAYES_50,FREEMAIL_FROM,KAM_THEBAT,SPF_SOFTFAIL autolearn=no version=3.3.2 spammy=H*UA:Bat!, H*x:Bat!, Repin, repin X-HELO: smtp.ht-systems.ru Received: from smtp.ht-systems.ru (HELO smtp.ht-systems.ru) (78.110.50.177) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 06 May 2016 14:35:20 +0000 Received: from [95.165.144.62] (helo=darkdragon.lan) by smtp.ht-systems.ru with esmtpa (Exim 4.80.1) (envelope-from ) (Authenticated sender: postmaster@rootdir.org) id 1aygqX-000731-GS ; Fri, 06 May 2016 17:35:13 +0300 Received: from [192.168.1.10] (HELO daemon2.darkdragon.lan) by daemon2 (Office Mail Server 0.8.12 build 08053101) with SMTP; Fri, 06 May 2016 14:20:40 -0000 Date: Fri, 06 May 2016 14:35:00 -0000 From: Andrey Repin Reply-To: cygwin@cygwin.com Message-ID: <967954968.20160506172040@yandex.ru> To: "David Allsopp" , cygwin@cygwin.com Subject: Re: Formatting command line arguments when starting a Cygwin process from a native process In-Reply-To: <000101d1a76d$c37c6b80$4a754280$@metastack.com> References: <005c01d1a6e2$30270ba0$907522e0$@metastack.com> <000101d1a76d$c37c6b80$4a754280$@metastack.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2016-05/txt/msg00070.txt.bz2 Greetings, David Allsopp! > [With apologies if threading is broken; I erroneously thought as the list > was not subscriber-only that replies would use reply-all and so wasn't subscribed] As long as your mail client is fine, you're fine. > I'm not using cmd, or any shell for that matter (that's > actually the point) - I am in a native Win32 process invoking a Cygwin > process directly using the Windows API's CreateProcess call. As it happens, > the program I have already has the arguments for the Cygwin process in an > array, but Windows internally requires a single command line string (which > is not in any related to Cmd). Then all you need is a rudimentary quoting. The rest will be handled by getopt when the command line is parsed. >> However, I've found Windows's interpretation to be inconsistent, so often >> have to play with it to find what the "right combination" is for a >> particular instance. >> >> I find echoing the parameters to a temporary text file and then using the >> file as input to be more reliable and easier to troubleshoot, and it >> breaks apart whether it is Windows cli inconsistencies or receiving >> program issues very nicely with the text file content as an intermediary > This is an OK tack, but I don't wish to do this by experimentation and get > caught out later by a case I didn't think of, so what I'm trying to > determine is *exactly* how the Cygwin DLL processes the command line via its > source code so that I can present it with my argv array converted to a > single command line and be certain that the Cygwin will recover the same argv DLL. > My reading of the relevant sources suggests that with globbing disabled, > backslash escape sequences are *never* interpreted (since the quote function > returns early - dcrt0.cc, line 171). If there is no way of encoding the > double quote character, then perhaps I have to run with globbing enabled but > ensure that the globify function will never actually expand anything - but > as that's a lot of work, I was wondering if I was missing something with the simpler "noglob" case. The point being, when you pass the shell and enter direct process execution, you don't need much of shell magic at all. Shell conventions designed to ease interaction between system and operator. But you have a system talking to the system, you can be very literal. -- With best regards, Andrey Repin Friday, May 6, 2016 17:18:00 Sorry for my terrible english... -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple