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@winehq.org ReportedBy: atohom@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.
http://bugs.winehq.org/show_bug.cgi?id=25901
Dan Kegel dank@kegel.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |dank@kegel.com
--- Comment #1 from Dan Kegel dank@kegel.com 2011-01-27 11:48:22 CST --- Thanks for the test case. Where does this problem affect you in real life? Do you have an app that this breaks?
http://bugs.winehq.org/show_bug.cgi?id=25901
Austin English austinenglish@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |download, testcase
http://bugs.winehq.org/show_bug.cgi?id=25901
--- Comment #2 from atohom@gmail.com 2011-01-27 13:46:57 CST --- (In reply to comment #1)
Thanks for the test case. Where does this problem affect you in real life? Do you have an app that this breaks?
I found this problem when working with FAR Manager (http://farmanager.com/), it uses cmd to launch another programs and that programs often get incorrect command line.
http://bugs.winehq.org/show_bug.cgi?id=25901
Roumen Petrov bugtrack@roumenpetrov.info changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |bugtrack@roumenpetrov.info
--- Comment #3 from Roumen Petrov bugtrack@roumenpetrov.info 2011-06-15 16:25:17 CDT --- I think this is reason some python 3+ tests to fail on wine up to 1.3.16.
http://bugs.winehq.org/show_bug.cgi?id=25901
Vijay Kamuju infyquest@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |infyquest@gmail.com
--- Comment #4 from Vijay Kamuju infyquest@gmail.com 2011-09-09 15:38:55 CDT --- please test with wine 1.3.28
http://bugs.winehq.org/show_bug.cgi?id=25901
--- Comment #5 from Roumen Petrov bugtrack@roumenpetrov.info 2011-09-11 12:36:35 CDT --- not fixed in 1.3.28
http://bugs.winehq.org/show_bug.cgi?id=25901
Frédéric Delanoy frederic.delanoy@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW CC| |frederic.delanoy@gmail.com Ever Confirmed|0 |1
--- Comment #6 from Frédéric Delanoy frederic.delanoy@gmail.com 2011-09-13 13:40:26 CDT --- Confirmed in 1.3.28
http://bugs.winehq.org/show_bug.cgi?id=25901
--- Comment #7 from Frédéric Delanoy frederic.delanoy@gmail.com 2011-11-09 19:44:54 CST --- Martin Wilck gave a shot at fixing this, but his patches weren't committed (and it seems he has lost interest/motivation in getting those in).
See http://www.winehq.org/pipermail/wine-patches/2011-September/107362.html http://www.winehq.org/pipermail/wine-patches/2011-September/107364.html http://www.winehq.org/pipermail/wine-patches/2011-September/107368.html http://www.winehq.org/pipermail/wine-patches/2011-September/107371.html http://www.winehq.org/pipermail/wine-patches/2011-September/107374.html http://www.winehq.org/pipermail/wine-patches/2011-September/107363.html
http://bugs.winehq.org/show_bug.cgi?id=25901
Jason Edmeades us@edmeades.me.uk changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |us@edmeades.me.uk AssignedTo|wine-bugs@winehq.org |us@edmeades.me.uk
http://bugs.winehq.org/show_bug.cgi?id=25901
Jason Edmeades us@edmeades.me.uk changed:
What |Removed |Added ---------------------------------------------------------------------------- Fixed by SHA1| |f252e9dfc85303d645ec545f238 | |fd8ee11ff2497 Status|NEW |RESOLVED Resolution| |FIXED
--- Comment #8 from Jason Edmeades us@edmeades.me.uk 2012-10-03 16:12:02 CDT --- Fixed in todays commits:
jason@jason-VirtualBox:/media/sf_wine$ wine test.exe "test.exe" "1 2 3" "test.exe" ""1 2 3"" test.exe " 1 test.exe "" test.exe "/"
http://bugs.winehq.org/show_bug.cgi?id=25901
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #9 from Alexandre Julliard julliard@winehq.org 2012-10-12 13:35:23 CDT --- Closing bugs fixed in 1.5.15.