[Bug 425510] Re: 'bzr mv' should do wildcard expansion on windows

John Arbash Meinel john at arbash-meinel.com
Wed Sep 9 15:13:35 BST 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Vincent Ladeuil wrote:
>>>>>> "martin" == Martin Pool <mbp at canonical.com> writes:
> 
> <snip/>
> 
>     martin> Perhaps a better way to tackle this is for the
>     martin> declaration of the argument pattern taken by the
>     martin> command to declare which arguments will be subject to
>     martin> expansion?
> 
> +1
> 
>         Vincent
> 
> 

So there is actually a way to get access to the original command line
string that was passed. If you look at:
 bzrlib.win32utils.get_unicode_argv

it does:
  pargv = CommandLineToArgv(GetCommandLine(), ctypes.byref(c))

GetCommandLine() gives you the raw Unicode string as supplied by the
caller. Which means that it has all the quoting characters, etc.

So we could simply replace "CommandLineToArgv()" with a function that
was more 'Unixy'.

I only realized recently that GetCommandLine() existed, and gave you the
fully quoted text.

It is a little bit tricky, but you can play around with it with:

python -c "from ctypes import *;" \
 "f = windll.kernel32.GetCommandLineW"\
 "GetCommandLine = WINFUNCTYPE(c_wchar_p)(f)"\
 "print repr(GetCommandLine())"

You can add extra arguments, etc. Note that it also indicates that when
running under 'python' we will need to be careful to strip off the
arguments to python which are separate from the arguments to our
function. (We already do some of that in get_unicode_arg()).

Also for *me personally* I actually run under Cygwin as my shell,
running the native Win32 client. Which means my shell will do the
automatic expansion and interpretation of "" and '', which means things
will probably break for me. But we certainly could do it.

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkqnuA8ACgkQJdeBCYSNAAM7mgCgmXFcldsxv/Seu3GOCopflxmi
YcYAoIIHFDllgEYeqQWsrkWI2xZXIhxi
=hHKj
-----END PGP SIGNATURE-----



More information about the bazaar mailing list