delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/08/28/05:37:47

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
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
Message-ID: <431185F7.4040904@arcor.de>
Date: Sun, 28 Aug 2005 11:37:59 +0200
From: Mudi Obada <monglong AT arcor DOT de>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.11) Gecko/20050728
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: argv[0] parsing problem with -mno-cygwin
X-IsSubscribed: yes

Hello,

when i compile an application with `gcc -mno-cygwin` and execute it from
cmd.exe, argv parsing is broken for argv[0] when quotes are embedded in
the command used to launch the application.

For example, executing ` "."\argv0_bug "a"\b ` from cmd.exe gives

  arg0: .
  arg1: \argv_bug
  arg2: a\b

instead of

  arg0: .\argv_bug
  arg1: a\b

Note that this is only a problem with argv[0].

MinGW.org's binaries seem to behave as expected. I'm using gcc version
3.4.4 (cygming special) (gdc 0.12, using dmd 0.125).

Below is a shell script that demonstrates the problem.

Regards,

Mudi Obada

#--------------------------

#!/bin/sh

f=argv0_bug

cat <<__EOF__ > $f.c

int main(int argc, char * * argv)
{
        int i;
        for (i = 0; i < argc; i++) {
                printf("arg%d: %s\n", i, argv[i]);
        }
        return 0;
}

__EOF__

gcc -mno-cygwin $f.c -o $f

echo \".\"\\$f \"a\"\\b > ${f}-test.bat

cmd /c ${f}-test.bat


#--------------------------




--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


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