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=oz9dXDb3mFZKWXT1Qc3LnrDFg+KMr 9NL3Zj32wTLlEDHfGWgW8qJWCshYpcfZDlOxRtbYsRokkseqmL9LTipObNG5IBRd r3WRKW83XRHM8/TzVtLwbGO3BNd5odcr7xxtIpsjBu90nfzWE2jx2a3K5+yEDp7N moQxEdTkE5aY/g= 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=uT6JRXxHmfoeVaNwbi4e2siXbEo=; b=RfV ZN+9v1/1SGco/b+OxTZ5OFMBPoOIiA4yH2n2egXqcBvWA6b6XJfLNrZeTusPg4+D 89uXUmi5bq9BbWKObG5gSFlKq4V4QtM3wL+CpelL1btVzFFPCjvvbHYr8Cev6XK5 HAMFBZk05I04Y4pN+p0/L2A6T/Jo/EQe/kJm8y14= 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-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-yk0-f179.google.com MIME-Version: 1.0 X-Received: by 10.170.152.195 with SMTP id t186mr8879046ykc.78.1434567010296; Wed, 17 Jun 2015 11:50:10 -0700 (PDT) Date: Wed, 17 Jun 2015 21:50:10 +0300 Message-ID: Subject: Arguments parsing in cygwin executables From: Sasha Unknown To: cygwin AT cygwin DOT com Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes Hello. [Sorry if duplicate, previous message was sent from wrong address, so not sure if it reached.] ==Preamble== Some time ago I noticed that cygwin executables (e.g. bash, tar, echo & so on) handle specially *, {} and some other symbols in command-line, even when being invoked not from shell (e.g. programmatic invocation or cmd.exe). After some googling, I found CYGWIN=noglob setting, which fixed the issue. After enabling it I hoped that cygwin executables will start parsing command-line in a standard for Windows executables way (I am not talking about path translation, only about handling special characters and splitting command string into argv array). ==Main== It revealed that even with CYGWIN=noglob, cygwin executables parse command line differently from other windows executables. (Again, I underline: I'm talking about invocation from cmd.exe or programmatic invocation, not invocation from bash.) Concretely, the 3rd and 4th test-cases from here fail: https://msdn.microsoft.com/en-us/library/windows/desktop/17w5ykft(v=vs.85).aspx. (BTW, ironically, with CYGWIN=glob only 3rd test-case fails.) ==Questions== So, questions are: 1. Is this behavior intentional, or is it bug? 1a. If intentional: Maybe there is a way to force cygwin executables to perform command-line parsing in windows-canonical way (i.e. CommandLineToArgv-like)? (I am talking about splitting command string into argv array, not about path translation.) 2. In any case, could you point me to part of cygwin sources which is responsible for this? (In case of intentionality -- to understand what behavior I'm now forced to adopt to, in case of bug -- to possibly aid fixing.) ==Test cases== 1. I compiled code from the link above with g++. 2. And written simple simple script in bash: > #!/bin/bash > for a in "$@"; do echo "$((++i)): $a"; done (to be called like this: c:\cygwin\bin\bash.exe c:\script.sh args-to-test) Both have same behavior, which differs from canonical windows parsing. ==Additional== What I'm trying to do? I am trying to find proper way of passing parameters to cygwin executables from non-cygwin application (which doesn't even know that it's dealing with cywgin). I suppose that if one wants *nix-typical parsing, he will use some shell (e.g. bash), or at least CYGWIN=glob. BTW, in CYGWIN=glob mode, curly braces are handled wrongly (c:\cygwin\echo.exe {aa} should return {aa}, not aa; because no , or .. inside {}). -- 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