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:content-type :content-transfer-encoding:mime-version; q=dns; s=default; b=iC0 r3qFRdlhTHeDd6eqE+mxWaifUDyft32Um9a5glOAEkNxVxtQbwjTAnrqz0m/x4kA 1CWbQZNJeZbbmL30cK4eRcFRR1CrJrVlzqLqJi4UZuSnFmH9ztQb42F0GxNC8B1W bqKgmh5ngCJ5f80wSku4CTSdszfW7pUj6MpToIbY= 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:content-type :content-transfer-encoding:mime-version; s=default; bh=1PvrrOiTc RiGOSmiGxC0YAr1+sM=; b=lycoxfQVpc7WOLt8/sar23YdD0M4+YqCfYHsPMJal botEtgxGyc/G9d4HL5K8+A6vbzvdiYBk6NOv/XPIrxOaGrSKQb9eKgdyiWAdBuE+ BDJAxZ7HKV+AVlNURP4c8sIQ9afl2DmBNJlWQ5TPo6ePCbmppZ2O6xkd2r/DnaB0 2c= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , 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.9 required=5.0 tests=AWL,BAYES_00,KAM_ASCII_DIVIDERS,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mailuogwdur.emc.com X-DKIM: OpenDKIM Filter v2.4.3 mailuogwprd54.lss.emc.com tAQKUZCO004738 X-DKIM: OpenDKIM Filter v2.4.3 mailuogwprd54.lss.emc.com tAQKUZCO004738 From: "Gluszczak, Glenn" To: "cygwin AT cygwin DOT com" Subject: RE: Argument parsing with gcc compiled program Date: Thu, 26 Nov 2015 20:30:31 +0000 Message-ID: <91DCAC3CB99C724EB365BB64677FBE7B01DD6C@MX204CL04.corp.emc.com> Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-Sentrion-Hostname: mailusrhubprd04.lss.emc.com X-RSA-Classifications: Source Code, public Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id tAQKUt3J029393 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" ============================================================== For some reason when I compile a C program in gcc, double backslashes within quotes are stripped. But if I compile with Visual Studio this does not happen. I used a small test program to demonstrate. VS c:\msvc2010_SP1\VC>a.exe -s something "something d\:\\hello" Command-line arguments: argv[0] a.exe argv[1] -s argv[2] something argv[3] something d\:\\hello CL: a.exe -s something "something d\:\\hello" GCC $ ./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" Is there some compiler option or setting I'm unaware of? Thanks, Glenn =============================================================================== #include #include int main( int argc, // Number of strings in array argv char *argv[], // Array of command-line argument strings char **envp ) // Array of environment variable strings { int count; char *gcl; // Display each command-line argument. printf(" \nCommand-line arguments:\n" ); for( count = 0; count < argc; count++ ) printf( " argv[%d] %s\n", count, argv[count] ); gcl = GetCommandLine(); printf("CL: %s\n",gcl); } -- 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