Hi,
Some time ago I realized that the command line handling in Wine did
not work properly when arguments with spaces or double-quotes are
involved. For instance I would start a Wine application like this:
main "a b" c
and it would tell me something like this:
GetCommandLine=[./main a b c]
Or I would call CreateProcess(... "main \"a b\" c" ...) and main
would get:
main -> argc=4
0 [./main]
1 [a]
2 [b]
3 [c]
So I investigated this and found that
* double-quotes, '"', have the same meaning in win32 as in unix
(tested on Win95 & Win2000)
* backslash, '\', work as on unix, especially wrt double-quotes
* single-quotes, ''', have no special meaning
So CreateProcess(... "main \"a b\" c" ...) should give me:
GetCommandLine=[./main "a b" c]
main -> argc=3
0 [./main]
1 [a b]
2 [c]
I searched for places where we convert command lines to argv lists
and reciprocally and modified them to work as on windows. With this
patch things should be correct, whether you call a Wine application from
Unix, from another Wine application via CreateProcess, or if you call a
Unix application from Wine. There's just one little bit in the msvcrt
code which I treated in a separate patch (p20010902-cmdline2.diff).
In the process I wrote a few test applications:
* hello
regular hello world unix app
* main
A Wine console application which dumps its argc/argv and then calls
GetCommandLine, ...
You can also call it with a '-i' parameter to test
CommandLineToArgvW, except that _getws is not implemented in Wine so
you can only do that on windows
* winmain
A Wine Gui application which dumps lpCmdLine and then calls
__getmainargs, CommandLineToArgvW(GetCommandLineW), ...
* createp
Which reads a command line from stdin and calls CreateProcess with it
* spawnv
Reads a list of arguments from stdin and calls spawnv with it
(spawn* don't handle ' ' and '"', see
p20010902-cmdline3.diff)
* spawn
Same but the command is fixed
I know that there has been discussions about the command line
handling before and that some applications do very weird things. Please
test this patch and let me know how it goes.
--
Francois Gouget fgouget(a)free.fr
http://fgouget.free.fr/
If it stinks, it's chemistry. If it moves, it's biology.
If it does not work, It's computer science.