Fun with argv

lawson_whitney at juno.com lawson_whitney at juno.com
Sat Feb 16 16:30:43 CST 2002


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\" '

Yes, and why did you escapr this trailing quote? >>>>>>>>>>>>>>>>>>^^
>
> Here, I've used single quotes to delimit the string. I'll carry on this
> convention because it will get confusing otherwise.
>
It is plenty confusing enough.  What in the name of Babbage are you
trying to do?

> 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" '
>
No, you mangled it in the command line by excapint the trailing ".

> 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'

Now again, why in the name of Babbage do you want to do this?
>
> 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"

I didn't do the command line quoting, but I've tested it some, and I
think it is essentailly correct, given what the C runtime routine is
going to do to split out argv[] again.  What is it you are trying to do?
Okay, maybe it is not exactly intuitive that "D:\office" is a directory
name (the \ is not an escape) but "D:\office\" is wrong.  If you want
that trailing \ to come out in the argv, (after the C runtime has had
its way with it) you need to escape the \, not the ",
so:  "D:\office\\".

Lawson
---oof---





More information about the wine-devel mailing list