public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: "Ziser, Jesse" <xezlec@yahoo.com>
To: cygwin@cygwin.com
Subject: Re: syntax for Cygwin bash invoking Win apps
Date: Wed, 09 Sep 2009 15:27:00 -0000	[thread overview]
Message-ID: <796377.93249.qm@web30205.mail.mud.yahoo.com> (raw)

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

Huh?  Last time I checked, bash translates "\"abc\"" to "abc".

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

Does "handles quoting" mean that it implements the "Quoting" section, and only that section, of the bash manpage?  I just need to know exactly what it does.  It clearly does not *only* do quoting.  That's why I demonstrated the asterisk example.  It is doing at least wildcard expansion in addition to quoting.  What else is it doing?  I'm trying to figure this out so I know how to properly escape or quote a general command in order to execute it from a Windows application without any unexpected changes.

Thanks for the response,
Jesse



      

--
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:[~2009-09-09 15:27 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-09 15:27 Ziser, Jesse [this message]
2009-09-09 15:57 ` Mark J. Reed
2009-09-09 16:05   ` Christopher Faylor
2009-09-09 16:10     ` Mark J. Reed
2009-09-09 16:31       ` Ziser, Jesse
2009-09-09 17:45       ` Christopher Faylor
2009-09-09 18:21         ` Ziser, Jesse
2009-09-09 18:41           ` Mark J. Reed
2009-09-09 16:10 ` Larry Hall (Cygwin)
  -- strict thread matches above, loose matches on Subject: below --
2009-09-09 15:57 Ziser, Jesse
2009-09-22 19:28 ` Ziser, Jesse
2009-09-09  3:30 Ziser, Jesse
2009-09-09  4:31 ` Matt Wozniski
2009-09-09  4:40 ` Larry Hall (Cygwin)

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=796377.93249.qm@web30205.mail.mud.yahoo.com \
    --to=xezlec@yahoo.com \
    --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).