This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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:cygwin@cygwin.com
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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]