dumb escaping question when using Cygwin + NT commands

Randall R Schulz rrschulz@cris.com
Thu Sep 19 09:25:00 GMT 2002


Scott,

[ This is off-topic for the Cygwin list, since it has nothing to do with 
Cygwin per se, but I feel the need to correct misconceptions for other 
newcomers to a Unix / POSIX (-like) environment, so I'm replying to the 
list, not just Scott. -- Randall ]


At 08:12 2002-09-19, Scott Prive wrote:

> > -----Original Message-----
>...
>
>Doh!
>
>Thanks. A good nights sleep and coffee got me thinking about this on the 
>way to work, and then I read your post.
>
>I misled myself because the ECHO command "worked". A debugging habit from 
>Perl is I would print out my variables. Since the echo worked, I never 
>questioned what I was doing with quotes.
>
>I assumed quotes controlled how data gets sent to commands, but apparently 
>that's an oversimplification: quotes protect data being sent to a NEW 
>PROCESS.. and builtins like "echo" are NOT a new process (`type echo). 
>This explains why the echo command understood what the heck was inside 
>'$2', but the echo command did not.

Not quite. The "echo" command printed the values of the positional 
parameters because the single quotes that immediately surrounded them were 
rendered into literal characters in the single argument to echo by the use 
of a pair of double quotes enclosing that whole (single) argument to echo. 
If you remove those double quotes, you'll see echo printing the $1, $2 
(literally).

The shell most certainly does not treat built-in and external commands 
differently as far as argument and I/O redirection (e.g.) are concerned.


>Of course you know this; I'm just filling in the blanks for the benefit of 
>mailing list and Google searches. For all of last night, I actually 
>believed the problem was due to mixing NT commands and Cygwin.
>
>Thanks again.


You're welcome.

Randall Schulz
Mountain View, CA USA


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



More information about the Cygwin mailing list