Argument parsing with gcc compiled program
Gluszczak, Glenn
glenn.gluszczak@emc.com
Fri Nov 27 16:34:00 GMT 2015
>-----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
More information about the Cygwin
mailing list