From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4619 invoked by alias); 8 Apr 2016 04:42:54 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 4609 invoked by uid 89); 8 Apr 2016 04:42:53 -0000 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 Received: from mail-lb0-f196.google.com (HELO mail-lb0-f196.google.com) (209.85.217.196) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 08 Apr 2016 04:42:43 +0000 Received: by mail-lb0-f196.google.com with SMTP id vk4so7847822lbb.1 for ; Thu, 07 Apr 2016 21:42:42 -0700 (PDT) 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) Received: by 10.25.23.77 with HTTP; Thu, 7 Apr 2016 21:42:39 -0700 (PDT) Date: Fri, 08 Apr 2016 04:42:00 -0000 Message-ID: Subject: Strange quoting behaviour using cygwin utilities outside shell From: Anthony Sottile To: cygwin@cygwin.com Content-Type: text/plain; charset=UTF-8 X-SW-Source: 2016-04/txt/msg00157.txt.bz2 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 . 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