This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Argument parsing with gcc compiled program


>-----Original Message-----
>From: Jan Nijtmans [mailto:jan.nijtmans@gmail.com] 
>Sent: Friday, November 27, 2015 4:30 AM
>To: cygwin@cygwin.com
>Subject: Re: Argument parsing with gcc compiled program
>
>2015-11-26 21:30 GMT+01:00 Gluszczak, Glenn <glenn.gluszczak@emc.com>:
>> Sorry I should have specified, this is not bash as this happens with 
>> the gcc compiled program within a Command Prompt session.
>>
>>
>> K:\>a.exe -s something "something d\:\\hello"
>>
>> Command-line arguments:
>>   argv[0]   a
>>   argv[1]   -s
>>   argv[2]   something
>>   argv[3]   something d\:\hello
>> CL: K:\sat-misc\src\sat-main\sat\src\wiz\a -s something "something d\:\hello"
>
>I think it's both "bash" and "cmd.exe" who do backslash substitution, even though they don't follow the same rules. gcc cannot do >anything about it.
>
>See:
><http://blogs.msdn.com/b/twistylittlepassagesallalike/archive/2011/04/23/everyone-quotes-arguments-the-wrong-way.aspx>

>Regards,
>          Jan Nijtmans


The parsing rules clearly state that arguments are only affected by quotes.
"Backslashes are interpreted literally, unless they immediately precede a double quotation mark."
https://msdn.microsoft.com/en-us/library/17w5ykft.aspx

Please look at my example again.  The same program compiled with Visual Studio does *not*
strip out the backslash whether run in cmd.exe or bash.exe.  Other utilities like Perl
do not strip out the backslash either.  It is only programs I compile with Cygwin gcc that do this.

Glenn

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]