delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/07/28/09:52:13

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Reply-To: <tawee007 AT ji-net DOT com>
From: "Tawee Laoitichote" <tawee007 AT ji-net DOT com>
To: <cygwin AT cygwin DOT com>
Subject: RE: Mangling of '\\' by cygwin dll
Date: Wed, 28 Jul 2004 20:51:57 +0700
Organization: PEA, Bangkok, Thailand.
Message-ID: <008101c474aa$0cf435d0$271f9ccb@Tawee2004>
MIME-Version: 1.0
In-Reply-To: <20040728084033.GC12700@cygbert.vinschen.de>
X-Virus-Scanned: by AMaViS-perl11-milter (http://amavis.org/)
X-IsSubscribed: yes

unsubscribe

-----Original Message-----
From: cygwin-owner AT cygwin DOT com [mailto:cygwin-owner AT cygwin DOT com] On Behalf
Of Corinna Vinschen
Sent: Wednesday, July 28, 2004 3:41 PM
To: cygwin AT cygwin DOT com
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:cygwin AT cygwin DOT 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/


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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019