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]

argv[0] parsing problem with -mno-cygwin


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/


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