Fun with argv

Dan Kegel dank at kegel.com
Sat Feb 16 13:29:52 CST 2002


Might be nice to have a regression test to check whether
Wine behaves properly with respect to the commandline.

How would one go about writing one?  Would the existing
perl regression test stuff be useful?  Or would a shell
script also be needed (since at least part of the user
stories involve starting wine from the linux commandline,
which isn't something that fits in the portable regression
test scheme imho).
- Dan

Paul Millar wrote:
> 
> Here's the patch, BTW.
> 
> ChangeLog:
>   Remove support for double quotes within command arguments as standard
>   backslash escaping is incompatible with Windows.
> 
> Paul.
> 
> On Sat, 16 Feb 2002, Paul Millar wrote:
> > Hi everyone,
> >
> > I've been looking at the installer for Office97. You call setup.exe
> > which runs acmsetup.exe with a bunch of options, specifically:
> > 'E:\~MSSETUP.T\~msstfof.t\acmsetup /T Off97Pro.stf /S "D:\office\" '
> >
> > Here, I've used single quotes to delimit the string. I'll carry on this
> > convention because it will get confusing otherwise.
> >
> > The problem is build_argv() assumes the command line is suitably escaped
> > (as from a bash command line, for example), and so mangles the above line
> > to the following values:
> >  'E:\~MSSETUP.T\~msstfof.t\acmsetup'
> >  '/T'
> >  'Off97Pro.stf'
> >  '/S'
> >  'D:\office" '
> >
> > But, the fun continues as you can pass arguments to setup.exe, which
> > augment the arguments passed to acmsetup.exe, so running:
> >
> >   wine setup.exe 'a a' '"b "B'
> >
> > results in argv[] for setup.exe being:
> >   'setup.exe'
> >   'a a'
> >   '"b "B'
> >
> > setup.exe then calls GetCommandLineA, which returns:
> >   'setup.exe "a a" "\"b \"B"'
> >
> > and then it tries to exec
> >   'E:\~MSSETUP.T\~msstfof.t\acmsetup /T Off97Pro.stf /S "D:\office\" "a a"
> > "\"b \"B"'
> > A command line with both unix-style escaped quotes and normal text. The
> > build_argv result is:
> >   'E:\~MSSETUP.T\~msstfof.t\acmsetup'
> >  [...]
> >   '/S'
> >   'D:\office" a'
> >   'a "b'
> >   '"B'
> >
> > and subsequent call to GetCommandLineA returns:
> >   'E:\~MSSETUP.T\~msstfof.t\acmsetup /T Off97Pro.stf /S "D:\office\" a" "a
> > \"b" \"B'
> >
> > What a mess!
> >
> > >From what I can see, the problem is ENV_BuildCommandLine build a command
> > line that is \-escaped (" => \" and \ => \\). Windows programs might use
> > this as part of a WinExec call (as above), which in general is not
> > \-escaped.
> >
> > The only way around this problem (I could think of) is to stop
> > ENV_BuildCommandLine from \-escaping the command line. This implies that
> > we cannot accept double-quotes on the command line as part of an argument.
> >
> > I have a patch which is a hack-and-slash to remove the \-escaping and the
> > resulting build processes arguments consistently (and Office97 setup gets
> > a bit further). However, someone's obviously gone to the trouble of coding
> > in support for double-quotes, so is this needed? Is there an alternative
> > solution?





More information about the wine-devel mailing list