public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Anthony Sottile <asottile@umich.edu>
To: cygwin@cygwin.com
Subject: Strange quoting behaviour using cygwin utilities outside shell
Date: Fri, 08 Apr 2016 04:42:00 -0000	[thread overview]
Message-ID: <CA+dzEBkt7u3c_cXoQNzGbDv008PHTAphXxo=jSFfNLG=NZa7vg@mail.gmail.com> (raw)

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

             reply	other threads:[~2016-04-08  4:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-08  4:42 Anthony Sottile [this message]
2016-04-08 12:30 ` Eliot Moss

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CA+dzEBkt7u3c_cXoQNzGbDv008PHTAphXxo=jSFfNLG=NZa7vg@mail.gmail.com' \
    --to=asottile@umich.edu \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).