public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Re: Passing double quotes to DOS
       [not found] <CA+Ni7jNBd0WZu37OMiPEyvxwkgvYnDfonKoLjpuvNrZ95A9Rbw@mail.gmail.com>
@ 2015-05-03 20:06 ` Пётр Б.
  2015-05-03 20:10   ` Пётр Б.
  2015-05-03 20:21 ` Пётр Б.
  1 sibling, 1 reply; 9+ messages in thread
From: Пётр Б. @ 2015-05-03 20:06 UTC (permalink / raw)
  To: cygwin

https://cygwin.com/ml/cygwin/2002-02/msg00336.html


There was a statement saying that cygwin does everything to preserve double
quotes.

It does not. I was recently doing some symbolic links with "cmd /c mklink
"path" "filename" " recently and it was fine until I had a file with
ampersand.

If I type
cmd /c mklink "path" "filename"

cmd.exe is called without doubleqoutes (I use ProcExp to see cmd line).

If I type same thing in "Run" dialog of TaskManager, doublequotes are
passed as intended.


If I type
cmd /c mklink \"path\" \"filename\"

reverse slash spills to cmd line.

If I type
cmd /c mklink "\"path\"" "\"filename\""

reverse slash and all doubleqoutes spill to cmd line.


I really do not get it. How do I pass doubleqoutes to CMD? Problem is
not related to mklink or any internals of CMD and even bash - Cygwin
does not pass doubleqoutes instead.

Example:
echo "\"bbb\""
cmd /c echo "\"bbb\""

There must be an error somewhere on the CYGWIN/Windows boundary.

Can I somehow whitelist "cmd.exe" so it does not get special treatment?

CYGWIN_NT-6.1 USER 1.7.33-2(0.280/5/3) 2014-11-13 15:47 x86_64 Cygwin

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

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

* Re: Passing double quotes to DOS
  2015-05-03 20:06 ` Passing double quotes to DOS Пётр Б.
@ 2015-05-03 20:10   ` Пётр Б.
  2015-05-03 20:11     ` Пётр Б.
  0 siblings, 1 reply; 9+ messages in thread
From: Пётр Б. @ 2015-05-03 20:10 UTC (permalink / raw)
  To: cygwin

cygwin.com/ml/cygwin/2002-02/msg00336.html


There was a statement saying that cygwin does everything to preserve
double quotes.

It does not. I was recently doing some symbolic links with "cmd /c
mklink "path" "filename" " recently and it was fine until I had a file
with ampersand.

If I type
cmd /c mklink "path" "filename"

cmd.exe is called without doubleqoutes (I use ProcExp to see cmd line).

If I type same thing in "Run" dialog of TaskManager, doublequotes are
passed as intended.


If I type
cmd /c mklink \"path\" \"filename\"

reverse slash spills to cmd line.

If I type
cmd /c mklink "\"path\"" "\"filename\""

reverse slash and all doubleqoutes spill to cmd line.


I really do not get it. How do I pass doubleqoutes to CMD? Problem is
not related to mklink or any internals of CMD and even bash - Cygwin
does not pass doubleqoutes instead.

Example:
echo "\"bbb\""
cmd /c echo "\"bbb\""

There must be an error somewhere on the CYGWIN/Windows boundary.

Can I somehow whitelist "cmd.exe" so it does not get special treatment?

CYGWIN_NT-6.1 USER 1.7.33-2(0.280/5/3) 2014-11-13 15:47 x86_64 Cygwin

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

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

* Re: Passing double quotes to DOS
  2015-05-03 20:10   ` Пётр Б.
@ 2015-05-03 20:11     ` Пётр Б.
  0 siblings, 0 replies; 9+ messages in thread
From: Пётр Б. @ 2015-05-03 20:11 UTC (permalink / raw)
  To: cygwin

/cygwin.com/ml/cygwin/2002-02/msg00336.html   (Gmail keeps setting my
message type to HTML. Cannot get it to be plaintext if there is a link
inside the message)


There was a statement saying that cygwin does everything to preserve
double quotes.

It does not. I was recently doing some symbolic links with "cmd /c
mklink "path" "filename" " recently and it was fine until I had a file
with ampersand.

If I type
cmd /c mklink "path" "filename"

cmd.exe is called without doubleqoutes (I use ProcExp to see cmd line).

If I type same thing in "Run" dialog of TaskManager, doublequotes are
passed as intended.


If I type
cmd /c mklink \"path\" \"filename\"

reverse slash spills to cmd line.

If I type
cmd /c mklink "\"path\"" "\"filename\""

reverse slash and all doubleqoutes spill to cmd line.


I really do not get it. How do I pass doubleqoutes to CMD? Problem is
not related to mklink or any internals of CMD and even bash - Cygwin
does not pass doubleqoutes instead.

Example:
echo "\"bbb\""
cmd /c echo "\"bbb\""

There must be an error somewhere on the CYGWIN/Windows boundary.

Can I somehow whitelist "cmd.exe" so it does not get special treatment?

CYGWIN_NT-6.1 USER 1.7.33-2(0.280/5/3) 2014-11-13 15:47 x86_64 Cygwin

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

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

* Re: Passing double quotes to DOS
       [not found] <CA+Ni7jNBd0WZu37OMiPEyvxwkgvYnDfonKoLjpuvNrZ95A9Rbw@mail.gmail.com>
  2015-05-03 20:06 ` Passing double quotes to DOS Пётр Б.
@ 2015-05-03 20:21 ` Пётр Б.
  2015-05-05 14:47   ` cyg Simple
  1 sibling, 1 reply; 9+ messages in thread
From: Пётр Б. @ 2015-05-03 20:21 UTC (permalink / raw)
  To: cygwin

cygwinDOTcom/ml/cygwin/2002-02/msg00336.html   (Gmail keeps setting my
message type to HTML. Cannot get it to be plaintext if there is a link
inside the message)


There was a statement saying that cygwin does everything to preserve
double quotes.

It does not. I was recently doing some symbolic links with "cmd /c
mklink "path" "filename" " recently and it was fine until I had a file
with ampersand.

If I type
cmd /c mklink "path" "filename"

cmd.exe is called without doubleqoutes (I use ProcExp to see cmd line).

If I type same thing in "Run" dialog of TaskManager, doublequotes are
passed as intended.


If I type
cmd /c mklink \"path\" \"filename\"

reverse slash spills to cmd line.

If I type
cmd /c mklink "\"path\"" "\"filename\""

reverse slash and all doubleqoutes spill to cmd line.


I really do not get it. How do I pass doubleqoutes to CMD? Problem is
not related to mklink or any internals of CMD and even bash - Cygwin
does not pass doubleqoutes instead.

Example:
echo "\"bbb\""
cmd /c echo "\"bbb\""

There must be an error somewhere on the CYGWIN/Windows boundary.

Can I somehow whitelist "cmd.exe" so it does not get special treatment?

CYGWIN_NT-6.1 USER 1.7.33-2(0.280/5/3) 2014-11-13 15:47 x86_64 Cygwin

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

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

* RE: Passing double quotes to DOS
  2015-05-03 20:21 ` Пётр Б.
@ 2015-05-05 14:47   ` cyg Simple
  0 siblings, 0 replies; 9+ messages in thread
From: cyg Simple @ 2015-05-05 14:47 UTC (permalink / raw)
  To: cygwin

> 
> There was a statement saying that cygwin does everything to preserve double
> quotes.
> 


Where is that statement?

> It does not. I was recently doing some symbolic links with "cmd /c mklink "path"
> "filename" " recently and it was fine until I had a file with ampersand.
> 

It isn't Cygwin but the shell semantics that parse the double quotes.

> If I type
> cmd /c mklink "path" "filename"
> 
> cmd.exe is called without doubleqoutes (I use ProcExp to see cmd line).
> 

Because the shell (e.g. bash) processes the data within the quotes; that isn't Cygwin and would happen in any *NIX shell.  Use:

cmd /c mklink '"path"' '"filename"'

instead.  Note the ' before and after (dependent on left or right values) the ".

--
cyg Simple


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

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

* Re: Passing double quotes to DOS
  2002-02-07  3:30   ` Richard Gilbert
@ 2002-02-07  8:21     ` Pavel Tsekov
  0 siblings, 0 replies; 9+ messages in thread
From: Pavel Tsekov @ 2002-02-07  8:21 UTC (permalink / raw)
  To: Richard Gilbert; +Cc: cygwin

Well, I got curious and examined the source more closely. This is
a commment from spawn.cc spawn_guts function:

	      /* Handle embedded special characters " and \.
		 A " is always preceded by a \.
		 A \ is not special unless it precedes a ".  If it does,
		 then all preceding \'s must be doubled to avoid having
		 the Windows command line parser interpret the \ as quoting
		 the ".  This rule applies to a string of \'s before the end
		 of the string, since cygwin/windows uses a " to delimit the
		 argument. */

It explains why you get: echo "\"abc\""

Now the more interesting thing is that it looks like different
types of command shell builtins will parse this in a different
way :) For example:

copy "\"abc\"" C:\
tries to copy  all files from  directory \abc\ :)

echo "\"abc\""
just prints everything passed to it as is :)

This leads me to the idea that cmd.exe / command.com
doesn't care about quoteing but every command does it
for itself :) Which is funny IMO :) Tried this on NT4 -
maybe anyone else can confirm / deny this for other windowses.

Btw this makes me think that the code that does all this
magic to protect double quote characters is quite unnecesary
since it can lead to misleading results.

just my two cents.


Richard Gilbert wrote:

>>>I need to be able to pass double quotes to a program running under NT4/DOS
>>>but I cannot find a way of doing so.  To illustrate the problem I have
>>>written a trivial BAT file called e.bat which contains the single line
>>>
>>>echo %1
>>>
>>>If I run it from a DOS shell with a double quoted parameter it echoes the
>>>parameter with the double quotes intact, e.g.
>>>
>>>C:>e.bat "abc"
>>>C:>echo "abc"	(<-- the BAT file echoes the command)
>>>"abc"
>>>
>>>However, if I run this program from a bash shell (or tcsh) in the cygwin
>>>environment, I cannot find a way of passing the double quotes to the
>>>program...
>>>
>>>$ e.bat "abc"
>>>C:>echo abc
>>>abc
>>>
>>>(as expected)
>>>
>>>$ e.bat "\"abc\""
>>>C:>echo "\"abc\""
>>>echo "\"abc\""
>>>
>>>$ e.bat '"abc"'
>>>C:>echo "\"abc\""
>>>echo "\"abc\""
>>>
>>I dont understand the output of the last example ? Is it really the
>>same like the output of the second sample or it's just copy and
>>paste mistake ? (DISCLAIMER: My understanding of shell scripts is not
>>that deep so if I'm asking something very stupid here, please ignore it)
>>
> 
> It really is the same...
> 
> 
>>>Note that both the last two result in the same command being passed to
>>>the BAT file.
>>>
>>>Can anybody tell me how to do it?
>>>
>>Does this help: e.bat \"abc\"
>>
> 
> ...and the above suggestion has exactly the same effect:
> 
> $ e.bat \"abc\"
> C:>echo "\"abc\""
> echo "\"abc\""
> 
> --
> Richard Gilbert
> Corporate Information and Computing Services
> University of Sheffield, Sheffield, S10 2TN, UK
> Phone: +44 114 222 3028   Fax: +44 114 222 3040
> 
> 
> --
> Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
> Bug reporting:         http://cygwin.com/bugs.html
> Documentation:         http://cygwin.com/docs.html
> FAQ:                   http://cygwin.com/faq/
> 
> 
> 
> 



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

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

* Re: Passing double quotes to DOS
  2002-02-07  3:17 ` Pavel Tsekov
@ 2002-02-07  3:30   ` Richard Gilbert
  2002-02-07  8:21     ` Pavel Tsekov
  0 siblings, 1 reply; 9+ messages in thread
From: Richard Gilbert @ 2002-02-07  3:30 UTC (permalink / raw)
  To: Pavel Tsekov; +Cc: cygwin

> > I need to be able to pass double quotes to a program running under NT4/DOS
> > but I cannot find a way of doing so.  To illustrate the problem I have
> > written a trivial BAT file called e.bat which contains the single line
> >
> > echo %1
> >
> > If I run it from a DOS shell with a double quoted parameter it echoes the
> > parameter with the double quotes intact, e.g.
> >
> > C:>e.bat "abc"
> > C:>echo "abc"	(<-- the BAT file echoes the command)
> > "abc"
> >
> > However, if I run this program from a bash shell (or tcsh) in the cygwin
> > environment, I cannot find a way of passing the double quotes to the
> > program...
> >
> > $ e.bat "abc"
> > C:>echo abc
> > abc
> >
> > (as expected)
> >
> > $ e.bat "\"abc\""
> > C:>echo "\"abc\""
> > echo "\"abc\""
> >
> > $ e.bat '"abc"'
> > C:>echo "\"abc\""
> > echo "\"abc\""
>
> I dont understand the output of the last example ? Is it really the
> same like the output of the second sample or it's just copy and
> paste mistake ? (DISCLAIMER: My understanding of shell scripts is not
> that deep so if I'm asking something very stupid here, please ignore it)

It really is the same...

> > Note that both the last two result in the same command being passed to
> > the BAT file.
> >
> > Can anybody tell me how to do it?
>
> Does this help: e.bat \"abc\"

...and the above suggestion has exactly the same effect:

$ e.bat \"abc\"
C:>echo "\"abc\""
echo "\"abc\""

--
Richard Gilbert
Corporate Information and Computing Services
University of Sheffield, Sheffield, S10 2TN, UK
Phone: +44 114 222 3028   Fax: +44 114 222 3040


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

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

* Re: Passing double quotes to DOS
  2002-02-07  2:48 Richard Gilbert
@ 2002-02-07  3:17 ` Pavel Tsekov
  2002-02-07  3:30   ` Richard Gilbert
  0 siblings, 1 reply; 9+ messages in thread
From: Pavel Tsekov @ 2002-02-07  3:17 UTC (permalink / raw)
  To: Richard Gilbert; +Cc: cygwin



Richard Gilbert wrote:

> I need to be able to pass double quotes to a program running under NT4/DOS
> but I cannot find a way of doing so.  To illustrate the problem I have
> written a trivial BAT file called e.bat which contains the single line
> 
> echo %1
> 
> If I run it from a DOS shell with a double quoted parameter it echoes the
> parameter with the double quotes intact, e.g.
> 
> C:>e.bat "abc"
> C:>echo "abc"	(<-- the BAT file echoes the command)
> "abc"
> 
> However, if I run this program from a bash shell (or tcsh) in the cygwin
> environment, I cannot find a way of passing the double quotes to the
> program...
> 
> $ e.bat "abc"
> C:>echo abc
> abc
> 
> (as expected)
> 
> $ e.bat "\"abc\""
> C:>echo "\"abc\""
> echo "\"abc\""
> 
> $ e.bat '"abc"'
> C:>echo "\"abc\""
> echo "\"abc\""


I dont understand the output of the last example ? Is it really the

same like the output of the second sample or it's just copy and
paste mistake ? (DISCLAIMER: My understanding of shell scripts is not 
that deep so if I'm asking something very stupid here, please ignore it)


> Note that both the last two result in the same command being passed to
> the BAT file.
> 
> Can anybody tell me how to do it?


Does this help: e.bat \"abc\"


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

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

* Passing double quotes to DOS
@ 2002-02-07  2:48 Richard Gilbert
  2002-02-07  3:17 ` Pavel Tsekov
  0 siblings, 1 reply; 9+ messages in thread
From: Richard Gilbert @ 2002-02-07  2:48 UTC (permalink / raw)
  To: cygwin

I need to be able to pass double quotes to a program running under NT4/DOS
but I cannot find a way of doing so.  To illustrate the problem I have
written a trivial BAT file called e.bat which contains the single line

echo %1

If I run it from a DOS shell with a double quoted parameter it echoes the
parameter with the double quotes intact, e.g.

C:>e.bat "abc"
C:>echo "abc"	(<-- the BAT file echoes the command)
"abc"

However, if I run this program from a bash shell (or tcsh) in the cygwin
environment, I cannot find a way of passing the double quotes to the
program...

$ e.bat "abc"
C:>echo abc
abc

(as expected)

$ e.bat "\"abc\""
C:>echo "\"abc\""
echo "\"abc\""

$ e.bat '"abc"'
C:>echo "\"abc\""
echo "\"abc\""

Note that both the last two result in the same command being passed to
the BAT file.

Can anybody tell me how to do it?

TYIA.

--
Richard Gilbert
Corporate Information and Computing Services
University of Sheffield, Sheffield, S10 2TN, UK
Phone: +44 114 222 3028   Fax: +44 114 222 3040



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

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

end of thread, other threads:[~2015-05-05 13:21 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CA+Ni7jNBd0WZu37OMiPEyvxwkgvYnDfonKoLjpuvNrZ95A9Rbw@mail.gmail.com>
2015-05-03 20:06 ` Passing double quotes to DOS Пётр Б.
2015-05-03 20:10   ` Пётр Б.
2015-05-03 20:11     ` Пётр Б.
2015-05-03 20:21 ` Пётр Б.
2015-05-05 14:47   ` cyg Simple
2002-02-07  2:48 Richard Gilbert
2002-02-07  3:17 ` Pavel Tsekov
2002-02-07  3:30   ` Richard Gilbert
2002-02-07  8:21     ` Pavel Tsekov

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).