delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2015/11/27/11:04:31

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:from:to:subject:date:message-id:references
:in-reply-to:content-type:content-transfer-encoding
:mime-version; q=dns; s=default; b=A4SMp+/1vfRyeMwgEzRrohhGdWVaG
jtHpKxcHsvA7BHMf7iGHAWwT8mnbjljvvDHBNp4mEq6YG1hbtOuuq9v3kiOdKQ13
gul+iXzXW94VRxauDkychLOEHLVoSHw3EtYJRPe9q3gy/Qnm/nI+rgmjKQdxmyv+
+VvIZbDCkwtka8=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:from:to:subject:date:message-id:references
:in-reply-to:content-type:content-transfer-encoding
:mime-version; s=default; bh=tOM7IW0YbJSvgiWEYmPo+A8KkpI=; b=IAz
9rEPhOhZ0oPh+i2k+jNw+l347mJINJt8AyjknpuEHJujLMjeTfAxWp4h3imburH+
YaJjlpy3lcf6kZD/uGgyfjP8ALVZ+o7IF69d+p8RtBF0xX+61WdUcRZWkFE0GyMk
TXLDOTMhVgntxAF2q7yXAFSc90xvRtH2pi/gOR5g=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=0.6 required=5.0 tests=AWL,BAYES_00,MIME_BASE64_BLANKS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2
X-HELO: mailuogwhop.emc.com
X-DKIM: OpenDKIM Filter v2.4.3 mailuogwprd04.lss.emc.com tARG48Po024094
X-DKIM: OpenDKIM Filter v2.4.3 mailuogwprd04.lss.emc.com tARG48Po024094
From: "Gluszczak, Glenn" <glenn DOT gluszczak AT emc DOT com>
To: "cygwin AT cygwin DOT com" <cygwin AT cygwin DOT com>
Subject: RE: Argument parsing with gcc compiled program
Date: Fri, 27 Nov 2015 16:03:53 +0000
Message-ID: <91DCAC3CB99C724EB365BB64677FBE7B01DF8C@MX204CL04.corp.emc.com>
References: <CAO1jNwu2RXpCn2JuaZEhGaFA4_UTW9dxPxRcoasRuUBwgbRQgA AT mail DOT gmail DOT com>
In-Reply-To: <CAO1jNwu2RXpCn2JuaZEhGaFA4_UTW9dxPxRcoasRuUBwgbRQgA@mail.gmail.com>
MIME-Version: 1.0
X-Sentrion-Hostname: mailusrhubprd01.lss.emc.com
X-RSA-Classifications: public
X-MIME-Autoconverted: from base64 to 8bit by delorie.com id tARG4Qjt002541

>-----Original Message-----
>From: Jan Nijtmans [mailto:jan DOT nijtmans AT gmail DOT com] 
>Sent: Friday, November 27, 2015 4:30 AM
>To: cygwin AT cygwin DOT com
>Subject: Re: Argument parsing with gcc compiled program
>
>2015-11-26 21:30 GMT+01:00 Gluszczak, Glenn <glenn DOT gluszczak AT emc DOT 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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019