delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2016/04/08/00:43:15

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:mime-version:date:message-id:subject:from:to
:content-type; q=dns; s=default; b=f9nmijkAUkPObtE+WmcWEFaxV8hcN
j6+t4MFOue1FX4IW3AEo9ctvM53LPOBXCBEQyJilhTipeGYJ9e7EujF0e3gHmaoy
ndKCrK0Cfm+Yx9DAYW8/g8hMA1sf7xdJGT9yoyXd6xbnMeQW1IwFNpn8Kh4Cr2js
WuDjb6fxF+InNA=
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:mime-version:date:message-id:subject:from:to
:content-type; s=default; bh=tjckk+nmie7cHJJUFtEy9WZL/Gs=; b=btH
rlTZU5ynAIb19HHM1EN0+aOL7U+Pfi5hFRSkhytOqKyNnvUukIUKr4jqx4DjIEme
xcZrtAbi60vs674sS2W/bXmURd7Q8UxdUpzfoMvQ8j4w6OM4iU9eML2my7ZzZ02Z
cQgZ0K8tax2+rZQn+RvYXbape7JXNtsnany2TEjs=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
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.7 required=5.0 tests=BAYES_20,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=fox, aims, extent, brian
X-HELO: mail-lb0-f196.google.com
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=NL9ApyTyp5Hlj/xChWkckclUi/oKHGN+SV69k+qkaK0=; b=Eu8DTkbg/lSE0o8znqVYT0Lh0VDhcZnNV/7rgBJMO2D887dPlToLu6o5Hevhefr62+ EwYPx4Rdv2pol/RiicwqpSF2P7C2s6qwFbdkfxt9ACzf8R28fa1f+tTkDiZXN9v/G/hh +QdkRsrAONynsi5rPBV/wmJnIc4AMMekLz8HA81xNI4bCgdxutR9dzsC4nqyQHvhrgTn r4W1JQ/zbIvR/I6LxdCYWbYQEziSNIEbSpRKs4293Ja1QpAVctlZgAIx77vZTUE/S0RT DMcFsBptsfjF7SD4doqnJCQJ7ZFmDFvkkp2Pd7gx4+ANsbJyQF2qcrn5i66a9OgHzp65 GYig==
X-Gm-Message-State: AD7BkJJrRfH0AxKtAOcmPHyOIjmgLnofppdaUVSFcSJYvTLCZN9ZUBfS2xXyEkRWGjYb5Vc2At3QVTmZumlVbKDs
MIME-Version: 1.0
X-Received: by 10.112.17.5 with SMTP id k5mr2751615lbd.46.1460090559875; Thu, 07 Apr 2016 21:42:39 -0700 (PDT)
Date: Thu, 7 Apr 2016 21:42:39 -0700
Message-ID: <CA+dzEBkt7u3c_cXoQNzGbDv008PHTAphXxo=jSFfNLG=NZa7vg@mail.gmail.com>
Subject: Strange quoting behaviour using cygwin utilities outside shell
From: Anthony Sottile <asottile AT umich DOT edu>
To: cygwin AT cygwin DOT com

I'm using cygwin utilities from outside cygwin (essentially
piggybacking on msysgit).  I'm writing a python application that aims
to target both POSIX systems and windows -- using cygwin utilities
seems like a perfect fit.

I'm using subprocess in python (under the hood it is essentially
CreateProcess calls).  I can't seem to get the quoting to work out in
a posix-compatible way:

```python
>>> ret = subprocess.call(('D:/tools/cygwin64/bin/echo.exe', '"hi"'))
\hi"
>>> ret = subprocess.call(('D:/tools/cygwin64/bin/echo.exe', '"hi"'), env={'CYGWIN': 'noglob'})
\hi\
```

The expected behaviour (demonstrated from ubuntu):

```python
>>> ret = subprocess.call(('lsb_release', '-a'))
No LSB modules are available.
Distributor ID:    Ubuntu
Description:    Ubuntu 15.04
Release:    15.04
Codename:    vivid
>>> ret = subprocess.call(('echo', '"hi"'))
"hi"
```

That is, to have echo.exe not mangle my quotes

Perhaps related:
https://github.com/git-for-windows/git/issues/561#issuecomment-162621304

If it's helpful, here's the strace output:
http://paste.pound-python.org/show/3pRuq1lAToCYKr8lKq7x/

Here's the version info, however I'm able to reproduce this in others
(including msys's versions):

```
Anthony AT AnthonysDesktop ~
$ /bin/echo.exe --version
echo (GNU coreutils) 8.25
Packaged by Cygwin (8.25-1)
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Brian Fox and Chet Ramey.

```

I believe to have traced the problem down to this line:

https://cygwin.com/git/gitweb.cgi?p=newlib-cygwin.git;a=blob;f=winsup/cygwin/dcrt0.cc;h=cbe7f25918;hb=HEAD#l187

I'm not sure what the correct fix is here, but I'm willing to assist
if possible :)

The examples above are using echo but it seems to happen with any
executable compiled for cygwin/msys -- the particular one I'm having
issue with is actually grep.

Thanks in advance!

Anthony

--
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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019