Mail Archives: cygwin/2009/07/01/06:37:44
Haojun Bao wrote:
> grischka <gr1008 AT googlemail DOT com> writes:
>
>> If I compile this snippet:
>>
>> #include <stdio.h>
>> int main (int argc, char **argv)
>> {
>> int i;
>> for (i = 0; i < argc; ++i)
>> printf("argv[%d] %s\n", i, argv[i]);
>> return 0;
>> }
>>
>> with cygwin GCC and then run it from CMD prompt:
>>
>> C:\cygwin\home\me> test \"stuff\"
>>
>> it prints this:
>>
>> argv[0] test
>> argv[1] \stuff"
>>
>> Is that expected? I'm aware that there is some conversion going on
>> and that it's meant to work from a cygwin shell really, but still.
>
> Yes, it's expected. The 1st `\' is not special to windows, so it get
> printed, the 1st `"' start a quote and it's removed, the 2nd `\' is in a
> quoted string, so it's removed but the 2nd `"' following it gets
> printed. And you didn't end your quoted string properly.
Indeed, it looks like that \ can escape " within "..." but not
outside.
That is per se logical, just that such logic doesn't seem to exist
neither in windows nor in posix. So I still wonder how it comes
into play.
> You can also try test "x""y", it should print `argv[1] x"y'
That looks more familiar like if it came from windows.
Then again, cygwin also parses "x:y""z" into x:y\z. Hm. Is this
now because me didn't quote properly or is it an artifact from the
posix/windows mix or is it something clever, under circumstances?
--- gr
--
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
- Raw text -