* Strange quoting behaviour using cygwin utilities outside shell
@ 2016-04-08 4:42 Anthony Sottile
2016-04-08 12:30 ` Eliot Moss
0 siblings, 1 reply; 2+ messages in thread
From: Anthony Sottile @ 2016-04-08 4:42 UTC (permalink / raw)
To: cygwin
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-04-08 12:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-08 4:42 Strange quoting behaviour using cygwin utilities outside shell Anthony Sottile
2016-04-08 12:30 ` Eliot Moss
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).