This is the mail archive of the
mailing list for the Cygwin project.
Re: syntax for Cygwin bash invoking Win apps
- From: "Ziser, Jesse" <xezlec at yahoo dot com>
- To: cygwin at cygwin dot com
- Date: Wed, 9 Sep 2009 09:31:11 -0700 (PDT)
- Subject: Re: syntax for Cygwin bash invoking Win apps
--- On Wed, 9/9/09, Mark J. Reed <firstname.lastname@example.org> wrote:
> From: Mark J. Reed <email@example.com>
> Subject: Re: syntax for Cygwin bash invoking Win apps
> To: firstname.lastname@example.org
> Date: Wednesday, September 9, 2009, 11:10 AM
> 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
> But even if I'm wrong about the details, bash has to be
> something different here.? On any other UNIX system,
> the "cmd" command
> would get an argv of ["cmd", "/c", "echo", "\"abc\""], but
> here it
> seems to be getting ["cmd", "/c", "echo", "\\\"abc\\\""].
Actually, in the case I gave, it looks more like it's getting ["cmd", "/c", "echo", "\"\\\"abc\\\"\""], which is even sillier.
But there's something else I just found: I wrote a Visual Studio application to just print out the arguments it gets, and for the command line:
$ cmd /c testme "\"hi\""
I get ["cmd", "/c", "testme", "\"hi\""], which is exactly what I would expect! Furthermore, it actually ADDS quotes in one case I just tried:
$ cmd /c echo \"hi\"
Where did those outer quotes come from? Maybe there are a combination of weird things going on. It almost seems like cmd.exe is somehow getting access to its command line before bash touches it, and it's using its own weird rules to decide how to parse that, but something somewhere (maybe bash?) is adding quotes in a futile attempt to make itself understood better?
Problem reports: http://cygwin.com/problems.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple