public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Mangling of '\\' by cygwin dll
@ 2004-07-24 21:34 Volker Quetschke
  2004-07-25 23:05 ` Volker Quetschke
  0 siblings, 1 reply; 5+ messages in thread
From: Volker Quetschke @ 2004-07-24 21:34 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 827 bytes --]

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.

 From cmd.exe:
C:\>\cygwin\bin\echo.exe '1 \ 2 \\ 3 \\\ 4 \\\\ 5 \\\\\ 6 \t'
1 \ 2 \ 3 \\ 4 \\ 5 \\\ 6 \t

It looks like each \\ is translated into \. Like escaping for
special characters, but it doesn't happen for single \.

This effect doesn't happen in bash:
$ /bin/echo.exe '1 \ 2 \\ 3 \\\ 4 \\\\ 5 \\\\\ 6 \t'
1 \ 2 \\ 3 \\\ 4 \\\\ 5 \\\\\ 6 \t

Bug or feature? I didn't find anything about this in
<http://cygwin.com/cygwin-ug-net/using-specialnames.html>.

Ah, yes,
$ uname -s -r
CYGWIN_NT-5.1 1.5.10(0.116/4/2)

Volker

-- 
PGP/GPG key  (ID: 0x9F8A785D)  available  from  wwwkeys.de.pgp.net
key-fingerprint 550D F17E B082 A3E9 F913  9E53 3D35 C9BA 9F8A 785D

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 254 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Mangling of '\\' by cygwin dll
  2004-07-24 21:34 Mangling of '\\' by cygwin dll Volker Quetschke
@ 2004-07-25 23:05 ` Volker Quetschke
  2004-07-28 13:59   ` Corinna Vinschen
  0 siblings, 1 reply; 5+ messages in thread
From: Volker Quetschke @ 2004-07-25 23:05 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 1112 bytes --]

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?

Volker

-- 
PGP/GPG key  (ID: 0x9F8A785D)  available  from  wwwkeys.de.pgp.net
key-fingerprint 550D F17E B082 A3E9 F913  9E53 3D35 C9BA 9F8A 785D

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 254 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Mangling of '\\' by cygwin dll
  2004-07-25 23:05 ` Volker Quetschke
@ 2004-07-28 13:59   ` Corinna Vinschen
  2004-07-28 14:23     ` Tawee Laoitichote
  2004-07-28 20:43     ` Volker Quetschke
  0 siblings, 2 replies; 5+ messages in thread
From: Corinna Vinschen @ 2004-07-28 13:59 UTC (permalink / raw)
  To: cygwin

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/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: Mangling of '\\' by cygwin dll
  2004-07-28 13:59   ` Corinna Vinschen
@ 2004-07-28 14:23     ` Tawee Laoitichote
  2004-07-28 20:43     ` Volker Quetschke
  1 sibling, 0 replies; 5+ messages in thread
From: Tawee Laoitichote @ 2004-07-28 14:23 UTC (permalink / raw)
  To: cygwin

unsubscribe

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


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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Mangling of '\\' by cygwin dll
  2004-07-28 13:59   ` Corinna Vinschen
  2004-07-28 14:23     ` Tawee Laoitichote
@ 2004-07-28 20:43     ` Volker Quetschke
  1 sibling, 0 replies; 5+ messages in thread
From: Volker Quetschke @ 2004-07-28 20:43 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 1285 bytes --]

Hi Corinna,

>>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.
Thanks, yes my small sed problem showed me that I also had to escape
the used \s in that file even though the single \ was conserved it
somehow confused sed.

Consequently using \\ fixes this.

Volker


-- 
If you like my work consider:  http://www.scytek.de/donations.html
PGP/GPG key  (ID: 0x9F8A785D)  available  from  wwwkeys.de.pgp.net
key-fingerprint 550D F17E B082 A3E9 F913  9E53 3D35 C9BA 9F8A 785D

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 254 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-07-28 14:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-07-24 21:34 Mangling of '\\' by cygwin dll Volker Quetschke
2004-07-25 23:05 ` Volker Quetschke
2004-07-28 13:59   ` Corinna Vinschen
2004-07-28 14:23     ` Tawee Laoitichote
2004-07-28 20:43     ` Volker Quetschke

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).