Fun with argv

Paul Millar paulm at astro.gla.ac.uk
Sun Feb 17 07:02:54 CST 2002


On Sat, 16 Feb 2002 lawson_whitney at juno.com wrote:

> On Sat, 16 Feb 2002, Paul Millar wrote:
> > 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? >>>>>>>>>>>>>>>>>>^^

I didn't. (and it isn't escaped: think Windows rather than *nix)

This command line is _from_ MS's setup.exe calling another program
acmsetup.exe. I didn't choose to have the quote marks around the
D:\office\ bit. Setup.exe doesn't do _any_ escaping. It's one of those
unfortunate things that, in this case, a non-escaped string looks like an
escaped one. If it didn't, we'd get away with the current command line
parsing.


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

Trying (and succeeding, to some extent ;) to get setup.exe working.

With the single quotes stuff, I was trying to show that there's a space at
the end of the command line. This turns out to be irrelevent, but I
thought it worth showing it.

If its too confusing, do
  sed -e "s/'//g" < email
and be done with them :^)

> > 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 ".

Nope. Setup.exe passed the command line with something that _looks_ like
its escaped. Wine's current behavour assumes command lines are escaped and
acts accordingly, thus it mangled the command line.


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

Its an awkward command line. I think it illustrates the problem with
escaping double quotes, because everything gets messed up. With the fix,
everything behaves "correctly", and the two extra arguments 'a a' and
'b B' are passed to acmsetup.exe correctly (without the offending double 
quotes).

[snip!]

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

I'm trying to fix an inconsistency. The problem is we're currently mixing
*nix-style command line (which _require_ double quotes to be escaped) with
Windows-style command lines (which have _no_ escaping). The only way you
can have the two mixed together is if you remove the possibility of having
double-quotes in an argument.

> Okay, maybe it is not exactly intuitive that "D:\office" is a directory
> name (the \ is not an escape) but "D:\office\" is wrong.

'fraid it can't be wrong. Its what setup.exe does and it works under 
Windows. If we want to support everything in Windows, we have to support 
this too.

Also, (please) correct me if I'm wrong, but AFAIK there is no way of
putting an escaped double quote into an argument within Windows. It
doesn't do escaping, so any " is treated as the start of a quoted region.

Because of this "blah\" is perfectly valid in Windows, but wrong on a *nix 
cmd line.

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

Well, more "D:\\office\\", but unfortunately Windows (or at least 
setup.exe) doesn't do it that way.


Cheers,

Paul.





More information about the wine-devel mailing list