# Fun with argv

lawson_whitney at juno.com lawson_whitney at juno.com
Sun Feb 17 10:05:35 CST 2002

On Sun, 17 Feb 2002, Paul Millar wrote:

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

Sorry, I can't.  Wine is as close to Windows as I ever got.
I'll think GCOS-8 or MVS if you like, but I don't think it will help.

>
> 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.
>
Okay, that makes a difference.  But you did put in those funky 'a a' and
'"b "B' things, no?
>
> 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 :^)

Singlle quotes are very useful and not awfully confusing.  What is
confusing is the Windows "cammand line" 8-D.
>
> 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.
>
Okay.  How would it be if we provided for a trailing backslash to not be
interpreted as an escape?  I am afraid if we rip out all escaping and
interpretation of escapes, we are going to make Wine more difficult to
use as a *nix program, which of coourse it is.
>
> 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).
>
The code here doesn't normally see quotes, single or double, after the
shell is done, but intuits that they were there if it sees spaces in a
*NIX argv string, so it puts them back when pasting the line back
together.

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

Wine is already better than Windows.  Now we just have to get a few
obscure features to work.
>
> 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.

That's what I was afraid of.  \ is handled correctly unless it comes
before " at the end of a string, I think.
>
> Well, more "D:\\office\\", but unfortunately Windows (or at least
> setup.exe) doesn't do it that way.
>
The whole thing was inside '', so you didn't need to escape \, unless it
comes before " or so, I think.
>
> Cheers,
>
> Paul.
>
Lawson

For Windows to triumph it is only necessary that good men do nothing.