Subject: RE: Mangling of '\\' by cygwin dll
From: "Tawee Laoitichote" <[email-masked]>
To: <[email-masked]>
Date: Wed, 28 Jul 2004 20:51:57 +0700

unsubscribe

-----Original Message-----
From: [email-masked] [mailto:[email-masked]] On Behalf
Of Corinna Vinschen
Sent: Wednesday, July 28, 2004 3:41 PM
To: [email-masked]
Subject: Re: Mangling of '\\' by cygwin dll

On Jul 25 15:15, Volker Quetschke wrote:
> Hi
> >I run into a strange problem while using sed from a cmd.exe shell.
> >
> >The problem is not sed specific and the following lines demonstrate 
> >it with /bin/echo.
> 
> The following mini program also demonstrates that it comes from the 
> cygwin dll.
> -- slashtest.c --
> #include <stdio.h>
> int main(int argc, char *argv[])
> {  printf("Arg1:%s:\n",argv[1]);
>   return 0;
> }
> -- slashtest.c end --
> 
> Compile it with "gcc slashtest.c -o slashtest_cyg.exe" and "gcc 
> -mno-cygwin slashtest.c -o slashtest_w32.exe" and try the following 
> from a cmd.exe:
> 
> C:\cygwin\bin>\cygwin\home\quetschke\slashtest_w32.exe '\\\'
> Arg1:'\\\':
> _nothing done for a native binary, the quotes stay_
> 
> C:\cygwin\bin>\cygwin\home\quetschke\slashtest_cyg.exe '\\\'
> Arg1:\':
> _Hmm, one \ escaped and one ' escaped, quotes vanish if not escaped._
> 
> C:\cygwin\bin>\cygwin\home\quetschke\slashtest_cyg.exe \\\
> Arg1:\\\:
> _Nothing special for a non-quoted string._
> 
> What is the deeper plan for this functionality?

Quotes are not treated specially in cmd.  But they are used in Cygwin to
allow applications called from cmd to get values which are otherwise
difficult to transport.  The rules are fairly simple and match your
obvservations.  A backslash is always a special character.  So a real
backslash has to be written as \\, the quoting character itself as
either \' or \", whatever you used for it.  That's it, basically.  So
your example '\\\' is treated as an unfinished quote with two
characters, a backslash and a single quote.

Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Co-Project Leader          mailto:[email-masked]
Red Hat, Inc.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/