[Bug 25901] New: Incorrect command line parsing in cmd

wine-bugs at winehq.org wine-bugs at winehq.org
Thu Jan 27 09:25:59 CST 2011


http://bugs.winehq.org/show_bug.cgi?id=25901

           Summary: Incorrect command line parsing in cmd
           Product: Wine
           Version: 1.3.12
          Platform: x86
        OS/Version: Linux
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: cmd
        AssignedTo: wine-bugs at winehq.org
        ReportedBy: atohom at gmail.com


#include <stdio.h>
#include <windows.h>

int main(int nargs, char *args[])
{
  if(nargs>1)
  {
    char *cl=GetCommandLine();
    printf("%s\n", cl);
  }
  else
  {
    STARTUPINFO si={sizeof(STARTUPINFO)};
    PROCESS_INFORMATION pi;
    CreateProcess(NULL, "cmd /C \"\"test.exe\" \"1 2 3\"\"", NULL, NULL, FALSE,
0, NULL, NULL, &si, &pi);
    WaitForSingleObject(pi.hProcess, INFINITE);
    CreateProcess(NULL, "cmd /C \"\"test.exe\" \"\"1 2 3\"\"\"", NULL, NULL,
FALSE, 0, NULL, NULL, &si, &pi);
    WaitForSingleObject(pi.hProcess, INFINITE);
    CreateProcess(NULL, "cmd /C test.exe \" 1", NULL, NULL, FALSE, 0, NULL,
NULL, &si, &pi);
    WaitForSingleObject(pi.hProcess, INFINITE);
    CreateProcess(NULL, "cmd /C test.exe \"\\\"", NULL, NULL, FALSE, 0, NULL,
NULL, &si, &pi);
    WaitForSingleObject(pi.hProcess, INFINITE);
    CreateProcess(NULL, "cmd /C test.exe \"/\"", NULL, NULL, FALSE, 0, NULL,
NULL, &si, &pi);
    WaitForSingleObject(pi.hProcess, INFINITE);
  }
  return 0;
}


On Windows this test program prints:

"test.exe"  "1 2 3"
"test.exe"  ""1 2 3""
test.exe  " 1
test.exe  "\"
test.exe  "/"

but in wine you get:

test.exe 1 2 3
test.exe 1 2 3
test.exe " 1"
test.exe \"
test.exe /


quote from cmd help on how it is supposed to work:

If /C or /K is specified, then the remainder of the command line after
the switch is processed as a command line, where the following logic is
used to process quote (") characters:

    1.  If all of the following conditions are met, then quote characters
        on the command line are preserved:

        - no /S switch
        - exactly two quote characters
        - no special characters between the two quote characters,
          where special is one of: &<>()@^|
        - there are one or more whitespace characters between the
          two quote characters
        - the string between the two quote characters is the name
          of an executable file.

    2.  Otherwise, old behavior is to see if the first character is
        a quote character and if so, strip the leading character and
        remove the last quote character on the command line, preserving
        any text after the last quote character.

-- 
Configure bugmail: http://bugs.winehq.org/userprefs.cgi?tab=email
Do not reply to this email, post in Bugzilla using the
above URL to reply.
------- You are receiving this mail because: -------
You are watching all bug changes.



More information about the wine-bugs mailing list