X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Message-ID: <4AA7318E.3070407@cygwin.com> Date: Wed, 09 Sep 2009 00:39:42 -0400 From: "Larry Hall (Cygwin)" Reply-To: cygwin AT cygwin DOT com User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.21) Gecko/20090320 Remi/2.0.0.21-1.fc8.remi Lightning/0.9 Thunderbird/2.0.0.21 Mnenhy/0.7.5.0 MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: Re: syntax for Cygwin bash invoking Win apps References: <883284 DOT 86806 DOT qm AT web30204 DOT mail DOT mud DOT yahoo DOT com> In-Reply-To: <883284.86806.qm@web30204.mail.mud.yahoo.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 On 09/08/2009 11:30 PM, Ziser, Jesse wrote: > Hello list, > > When I type a command in bash to invoke a Windows application (like > cmd.exe, for example), I can't seem to find a pattern in the Windows command > line that actually gets executed. Ordinary bash syntax does not seem to > apply in general when the command is a Windows app, but rather, sometimes > special characters are interpreted in a bash-like way, and sometimes not. > So, I'm wondering what determines whether a quote mark or something gets > interpreted or passed on. > > Here are some examples: > > $ cmd /c echo "/?" > Displays messages, or turns command-echoing on or off. > > ECHO [ON | OFF] > ECHO [message] > > Type ECHO without parameters to display the current echo setting. > > # OK, so I'm getting the Windows echo, not the bash echo. Good. > # Moving on... > $ cmd /c echo abc > abc > > $ cmd /c echo "abc" > abc > > $ cmd /c echo "\"abc\"" > "\"abc\"" > > # Wahhh?! > > Anyone who knows the explanation would make me very grateful. I've tried > this with other Windows apps too, and the same weirdness seems to occur. All of the above is consistent with bash shell quoting. It's the shell that does the interpreting in the Unix/Linux world and that's what you're seeing here. > On a related note, I've noticed what appears to be an automatic sort of half-bash invocation (but not quite?) or something when I run Cygwin commands from cmd.exe. For example, >> c:\cygwin\bin\echo hi > hi > >> c:\cygwin\bin\echo "hi" > hi > >> c:\cygwin\bin\echo "\"hi\"" > "hi" > >> c:\cygwin\bin\echo * > myfile myotherfile yetanotherfile ... > > And yet... > >> c:\cygwin\bin\echo $PATH > $PATH > > What the heck is going on? Are there any rules here at all? Sorry if I'm > missing something dumb. And sorry for apologizing for it. And...... In this case, the Cygwin DLL intercedes and handles quoting for the Cygwin app that you invoked (echo). But it only does quoting. You're mixing the notion of quoting with environment handling. They are two different things. -- Larry Hall http://www.rfk.com RFK Partners, Inc. (508) 893-9779 - RFK Office 216 Dalton Rd. (508) 893-9889 - FAX Holliston, MA 01746 _____________________________________________________________________ A: Yes. > Q: Are you sure? >> A: Because it reverses the logical flow of conversation. >>> Q: Why is top posting annoying in email? -- 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