Re: Still no luck on command line parse

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 1 Feb 2002 lawson_whitney@juno.com wrote:
[...]
> True.  If wine sees the effect of a quote the shell has removed (spaces
> in an argument), it will quote the string with \", because if it
> doesn't, the C runtime will parse the spaces:
>
> [whit@giftie cmdl]$ wine cmdl.exe "quoted string"
> arg 0: /cmdl.exe/
> arg 1: /quoted string/
> [whit@giftie cmdl]$ wine cmdl.exe \"quoted string\"
> arg 0: /cmdl.exe/
> arg 1: /"quoted/
> arg 2: /string"/
> [whit@giftie cmdl]$ wine --dll msvcrt=n cmdl.exe "quoted string"
> arg 0: /cmdl.exe/
> arg 1: /quoted string/
> [whit@giftie cmdl]$ wine --dll msvcrt=n cmdl.exe \"quoted string\"
> arg 0: /cmdl.exe/
> arg 1: /"quoted/
> arg 2: /string"/
> [whit@giftie cmdl]$

   This seems all very logical and I am pleased to note that native and
builtin msvcrt behave identically. Note that your test above should
really print GetCommandLine() too.


> I know, in my example, it is actually the unix shell that is breaking
> the argument in half, but I am confident the windows C runtime startup
> routines do the same.

   Well, the thing you have to understand is that Windows and Unix
handle things very differently. On Unix the new process does not receive
a command line but a string array. Argc/argv just point to that data. On
Windows the new process receives a single string which is the raw
command line.
   So what happens in Wine is that when a process invokes CreateProcess?
The command line is broken up into argc/argv, passed down to exec, then
the Wine startup code rebuilds the command line from there. If your
process has a main then it gets the original argc/argv (almost, Wine
still has to remove the wine specific options), and if it has a WinMain,
then it gets the rebuilt command line.
   And if you invoke Wine from the command line or from any Unix
process, there is no 'original commandline'. But Wine will rebuild one
from argc/argv just like it always does. Now, the only information loss
is at the level of the spaces between the arguments on the command line.
See this email for more details:
   http://www.winehq.com/hypermail/wine-devel/2002/01/0240.html


> Unlike the unix shell, they only preserve spaces
> in an argument quoted by \", and treat " as an ordinary character.

   Not true. Here is a test I did in Windows:

c:\>main.exe "quoted string"
GetCommandLine=[main.exe "quoted string"]
main -> argc=2
0 [main.exe]
1 [quoted string]
c:\>main.exe \"quoted string\"
GetCommandLine=[main.exe \"quoted string\"]
main -> argc=3
0 [main.exe]
1 ["quoted]
2 [string"]

   Windows handles " and \" just like the Unix shells do.


   See also:
http://www.winehq.com/hypermail/wine-devel/2001/09/0004.html


--
Francois Gouget         fgouget@free.fr        http://fgouget.free.fr/
                Linux: It is now safe to turn on your computer.


_______________________________________________
wine-users mailing list
wine-users@winehq.com
http://www.winehq.com/mailman/listinfo/wine-users

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux