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 18:21:00 -0000	[thread overview]
Message-ID: <622599.51453.qm@web30201.mail.mud.yahoo.com> (raw)
In-Reply-To: <20090909174534.GD29151@ednor.casa.cgf.cx>

--- On Wed, 9/9/09, Christopher Faylor <cgf-use-the-mailinglist-please@cygwin.com> wrote:

> From: Christopher Faylor <cgf-use-the-mailinglist-please@cygwin.com>
> Subject: Re: syntax for Cygwin bash invoking Win apps
> To: cygwin@cygwin.com
> Date: Wednesday, September 9, 2009, 12:45 PM
> On Wed, Sep 09, 2009 at 12:10:44PM
> -0400, Mark J. Reed wrote:
> >On Wed, Sep 9, 2009 at 12:05 PM, Christopher Faylor
> wrote:
> >>>>>> $ 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.
> >>>
> >>>Larry Hall:
> >>>>>All of the above is consistent with
> bash shell quoting.
> >>>
> >>>No, it's really not. ??Those backslashes should
> be long gone by the
> >>>time cmd.exe gets its arguments, yet it echoes
> them. ??It seems that
> >>>the Cygwin version of bash stops short before
> doing some of the work
> >>>it normally does itself on other systems,
> assuming the executed
> >>>command will have its command line run through
> the preprocessor in the
> >>>Cygwin DLL.
> >>
> >> Actually, I'd say that was cmd doing something
> funky. ??It's hard to believe
> >> that bash was actually special-casing cmd.exe.
> >
> >I don't think it's special-casing cmd.exe.  I
> think some of the
> >command line processing that is done by bash on Linux
> has been moved
> >out of bash and into the DLL command line preprocessor
> on Cygwin.
> 
> Cygwin does quote individual arguments if they contain
> "special"
> characters like quotes or spaces when sending a
> command-line to a
> windows program.  It's up to the windows program to
> understand quoting.

OK, yeah, I now see that is basically what's going on.  Bash is processing it as normal and then Cygwin is adding all kinds of quoting before invoking the Windows executable.

However, it does more than quote them (which would only bother me a little), because it also added backslashes in front of the quote-marks (see the following example, which I just discovered).

$ cmd /c echo '"hi"'
"\"hi\""

This does appear to give the right result ("hi") after standard Windows command line parsing for Windows apps I write, so I guess that's the best thing to do, but I don't really understand it... I mean how does Windows decide whether a backslash is an escape or just a backslash?  Well, that's not your problem, so I'll drop it.  I guess my scripts are just always going to be a little unpredictable -- the cost of doing business with Windows users.

Now, if I can just find out exactly which kinds of preprocessing steps Cygwin apps do on their arguments when called from Windows... but I guess I can just go through the bash manual and try each step, one at a time, to find out.

Thanks for the help, everyone.





--
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 18:21 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-09 15:27 Ziser, Jesse
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 [this message]
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=622599.51453.qm@web30201.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).