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:subject:to:references:from:message-id:date :mime-version:in-reply-to:content-type; q=dns; s=default; b=PS2F jI/hBSinIj8MVa/cFniyT9Gc2qSU0bHdcaF+6gWnyEpf336BJqjU2IsUkvWW+tni CsAt4r03HiG1hD1v95Kp9L43fZIgih78utBLYltgMEuXo4oyTO+2fuC3I7HTKtxc 7wy9X1CMjId9wQTNNE7jbMcD7UzoYw07lkrGwVQ= 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:subject:to:references:from:message-id:date :mime-version:in-reply-to:content-type; s=default; bh=l9ovTwwHwG AJwKVrBZwMPGlNIDg=; b=waRGBjtTf0iWXeELW63wzgzh6eJp0QMBJhYBoM171T CpflEZOdXqYsANYttwg7tMubIXwFu8/4n8t8t6p/ctd8J6+4mraklFsbWK2OVojH JL5fv2cqqY1JE3a3MFkTEw5Jd7lj8XVxBykJx4MeNI4rbZDEhSzrdhFL5aLSBSUW o= 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=-2.1 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mx1.redhat.com Subject: Re: Command line processing in dcrt0.cc does not match Microsoft parsing rules To: cygwin AT cygwin DOT com References: From: Eric Blake Openpgp: preference=signencrypt Message-ID: Date: Thu, 5 Sep 2019 20:26:36 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="43KnC78A6tPT4OgSmbqCwpP1EmPamV5C0" X-IsSubscribed: yes --43KnC78A6tPT4OgSmbqCwpP1EmPamV5C0 Content-Type: multipart/mixed; boundary="QbOQnRlfjxp9I2RkiWOxv2ylZLsBghhtN"; protected-headers="v1" From: Eric Blake To: cygwin AT cygwin DOT com Message-ID: Subject: Re: Command line processing in dcrt0.cc does not match Microsoft parsing rules References: In-Reply-To: --QbOQnRlfjxp9I2RkiWOxv2ylZLsBghhtN Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable On 9/5/19 6:45 PM, Stephen Provine via cygwin wrote: >=20 > To prove it is not going through cmd.exe, I debugged the Go program > to the point that it calls the Win32 CreateProcess function, and the > first two arguments are: >=20 > lpApplicationName: "C:\\cygwin64\\bin\\bash.exe" > lpCommandLine: "C:\\cygwin64\\bin\\bash.exe test.sh foo bar\\\"baz bat" And according to https://blogs.msdn.microsoft.com/twistylittlepassagesallalike/2011/04/23/ev= eryone-quotes-command-line-arguments-the-wrong-way/ that is NOT the correct command line to be handing to CreateProcess, at least not if you want things preserved. If I read that page correctly, the unambiguously correct command line should be: "C:\\cygwin64\\bin\\bash.exe test.sh foo \"bar\\\"baz\" bat" >=20 > So unless I'm missing something, bash.exe is not interpreting the command= line > following the rules pointed to by the documentation for CommandLineToArgv= W. Rather, go is not passing the command line to CreateProcess in the way that is unambiguously parseable in the manner expected by CommandLineToArgvW. And because Go is relying on a corner case of ambiguous parsing instead of well-balanced quoting, it's no surprise if cygwin doesn't parse that corner case in the manner expected. A patch to teach cygwin to parse the corner case identically would be welcome, but fixing recipient processes does not scale as well as fixing the culprit source process. --=20 Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org --QbOQnRlfjxp9I2RkiWOxv2ylZLsBghhtN-- --43KnC78A6tPT4OgSmbqCwpP1EmPamV5C0 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEccLMIrHEYCkn0vOqp6FrSiUnQ2oFAl1xtcwACgkQp6FrSiUn Q2q8KAf+KUU8c4xxtPG1mVnjlkCOZZwvJbvS6Hma2TObhx5nI0XvXU8Gh7nSXgbS xHyZ5YjvtDWGI8aNPlgsr6DlzDsf9z/B0ys/X7vb+yVJygdtJFkr4UNqNA4anZYe 1etnXKUj15Wh7/TZBM6DmqvNNN5j8H/abZr6WBywAec1TlpNgtaT8yHbmJKYoc0t if+9baW720WHU3VRSB/cMmHRD3iL+U+AS6v9Kyj5/3Nv+yt8fMluxVjjLVv3q0W2 EP+SwWNvGP8NDRLsmEOPeWI15ZHXVXJkqC4WQEMPURUmxAkzloTz/zBCVnvP58DV DzXj5XVLUsYknWHTnh74BciiawBdZg== =O2or -----END PGP SIGNATURE----- --43KnC78A6tPT4OgSmbqCwpP1EmPamV5C0--