delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/07/28/04:40:36

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
Date: Wed, 28 Jul 2004 10:40:33 +0200
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: Mangling of '\\' by cygwin dll
Message-ID: <20040728084033.GC12700@cygbert.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <4102A623 DOT 6090103 AT scytek DOT de> <410406E0 DOT 2000402 AT scytek DOT de>
Mime-Version: 1.0
In-Reply-To: <410406E0.2000402@scytek.de>
User-Agent: Mutt/1.4.2i

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/

- Raw text -


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