monotone-devel
[Top][All Lists]
Advanced

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

Re: [Monotone-devel] Re: Serving * does not work


From: Matthew Gregan
Subject: Re: [Monotone-devel] Re: Serving * does not work
Date: Thu, 13 Oct 2005 08:33:02 +1300
User-agent: Mutt/1.5.10i

At 2005-10-12T13:19:11+0200, Wim Oudshoorn wrote:
> Matthew Gregan <address@hidden> writes:
> 
> [Interesting explanation how expansion on MS windows work deleted]
> 
> >> So the ls command works fine.  Oh and it is not the fact
> >> that ls is part of msys.  If you replace ls with notepad.exe
> >> the expansion behaviour is correct as well.
> >
> > notepad.exe, like most native Windows applications, performs its own
> > glob expansion.
> 
> Ok, but why can't monotone?

It does, it's just using a different mechanism (the one supplied by MinGW).
With monotone on Windows right now, the glob expansion occurs before main()
is called, and _anything_ that looks like a glob will potentially be
expanded.

notepad.exe, on the other hand, is performing the glob expansion later
(probably at a time when it knows the glob expansion is expected to result
in a set of filenames), and has more control over it.

We could change monotone to perform its own globbing as needed.  This would
involve disabling MinGW's compatibility globbing that we're currently using,
and then implementing our own globbing functionality.  And then, the next
question is, what do we do?  Do we implement POSIX-like globbing behaviour
for consistency between platforms, or do we use the Win32 FindFirstFile()
API (and like with the large amount of ugly behaviour that brings with it)?

> To reword it slightly:
> 
> notepad "*"
> 
> will give an error it can not open the file * on the msys shell.

Okay, so the behaviour (within a MinGW shell) here would be:

notepad *
(MinGW shell performs glob expansion on *)

notepad "*"

(MinGW shell passes * through to application untouched because the quotes
are sufficient to escape the asterisk, application may perform glob
expansion if it feels like it)

And, as you say, in this second case, notepad will complain about an invalid
filename (because the * is passed through as an argument to FindFirstFile or
whatever mechanism they happen to use), and monotone will end up with a
fully expanded argument list (because the quotes have been stripped by the
MinGW shell, so the glob expansion code sees an unquoted * and goes to
work).

But, if you run monotone at a cmd.exe prompt with "*", it will receive an
unexpanded *!

If you compile the example FindFirstFile code from MSDN under MinGW, and add
the line "int _CRT_glob = 0;" above main (and also try a build with it set
to 1), you can experiment with the different behaviours in different shells.

And, yeah, I'll be the first to say that the current behaviour is
inconsistent and unpredictable... and isn't _exactly_ our fault. :-) This is
what you get for using a platform that shifts the responsibility for glob
expansion from the shell into each and every application.

> But monotone will still insist on expanding.
> So it seems notepad expansion algorithm is better than monotone's.
> 
> Oh not that this, IMO, warrant fixing.  If I am using the msys shell I
> should accept to live with the consequences :-)

It would be really nice to improve our behaviour in this area; it's just a
matter of deciding what the best thing to do is, and then spending some time
doing it.

Cheers,
-mjg
-- 
Matthew Gregan                     |/
                                  /|                address@hidden




reply via email to

[Prev in Thread] Current Thread [Next in Thread]