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:reply-to:subject:to:references:from:message-id :date:mime-version:in-reply-to:content-type :content-transfer-encoding; q=dns; s=default; b=ZTFLE+Y93WTy09Fl crGC639Ppdol7KxBMarHMuc8Z9YWHNXG05uToKKpoDom1ulPTPmxfBloVjeHQUUQ pw0nXYUjRpn05ApCGU8hJE11MG4UoOlHE3XW15JgZEUkBL37NkioQtTIV3baAA5G +R0E7bvaitVIk/RWff6EUhHYQ84= 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:reply-to:subject:to:references:from:message-id :date:mime-version:in-reply-to:content-type :content-transfer-encoding; s=default; bh=P7cy/tZouxzbxEgyZj71Ce aAfRo=; b=ROreucNEEALsQCgK5I9CAwrY6TQvTD/+EqERiALmbwgFEFGFZWDJJo rP8xDsOi9XRtNdkZ/q3p01pwBIrAfn92o4znwjnwcu/n94p4IwRiWu4kNNT9+1Dm cW0un7xZs7z4dGmOER9O42xG8VvzzaXG6HrHxY5YmdQJng0VDI2iA= 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-Spam-SWARE-Status: No, score=-3.0 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 spammy=blanks, 21062019, 21.06.2019, Brker X-HELO: smtp-out-so.shaw.ca Reply-To: Brian DOT Inglis AT SystematicSw DOT ab DOT ca Subject: Re: Process argument passing problems To: cygwin AT cygwin DOT com References: <5be40c24ed860fb56dc28523f464cadd5068c268 DOT camel AT gmail DOT com> <13855b6c-f65e-b07f-3f6f-4ffd5cb945a6 AT t-online DOT de> From: Brian Inglis Openpgp: preference=signencrypt Message-ID: <020308f0-60d2-33eb-78da-d086a476560f@SystematicSw.ab.ca> Date: Fri, 21 Jun 2019 15:13:17 -0600 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <13855b6c-f65e-b07f-3f6f-4ffd5cb945a6@t-online.de> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-IsSubscribed: yes On 2019-06-21 14:15, Hans-Bernhard Bröker wrote: > Am 21.06.2019 um 17:19 schrieb reiter DOT christoph AT gmail DOT com: >> I have to following problem (using cmd.exe): >> C:\cygwin64\home\xy>C:\cygwin64\bin\echo.exe -DFOO=\"BAR\" -DBAR=\"FOO\" >> -DFOO=\BAR" -DBAR="FOO" >> I would have expected: >> -DFOO="BAR" -DBAR="FOO" > 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. >> 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. >> More background: https://github.com/msys2/MINGW-packages/issues/3548 > Please note that that's about MSYS2, which, while closely related to > Cygwin, is not really the topic of this mailing list. Not only are you running from cmd, you are running Cygwin /bin/echo, which does additional command line parsing when not invoked from Cygwin. Please note that the cmd escape char is "^" caret/uparrow not backslash "\" so you might have more luck trying e.g. > \cygwin64\bin\echo ^"-DFOO=\"BAR\" -DBAR=\"FOO\" -DFOO="BAR" -DBAR="FOO" or > \cygwin64\bin\echo ^"-DFOO=\^"BAR\^" -DBAR=\^"FOO\^" -DFOO="BAR" -DBAR="FOO" depending on what you are trying to pass from where to what. All quotes and backslashes are stripped by shells while building the calling argv array, so you should only need a backslash or quotes to pass args with spaces from cmd to Cygwin programs, unless programs require quotes around option values, which gcc shouldn't. You will have to read up on the details of MSYS2 and Python command line parsing and how they pass command line arguments to WinExec(), ProcessCreate(), or ShellExecute() to run programs. Using Cygwin shells and python would make this a whole lot easier! -- Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada This email may be disturbing to some readers as it contains too much technical detail. Reader discretion is advised. -- 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