recursive commands?

John Arbash Meinel john at arbash-meinel.com
Fri Aug 7 14:46:37 BST 2009


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

Stephen J. Turnbull wrote:
> Martin Pool writes:
> 
>  > I think he means that the shell removes the doublequotes, so the
>  > process gets a list of strings.
> 
> COMMAND.COM does remove doublequotes as part of the process of
> variable expansion (I never learned much about CMD.EXE and/or
> successors).  However, it returns a single string, not a list.
> 
> ISTR that the original command string is available somewhere, I think
> DJGPP's C library parsed that itself rather than use the shell's
> semiparsed version.  I could be wrong, it's been 15 years....
> 
> 

So I believe the various functions are:
GetCommandLine = prototype(("GetCommandLineW",
                            ctypes.windll.kernel32))
CommandLineToArgv = prototype(("CommandLineToArgvW",
                               ctypes.windll.shell32))

which we do, in fact, use directly in bzrlib/win32tools.py

I just did a couple quick tests, and indeed "GetCommandLineW" returns a
single unicode string that has not done any work wrt quotations. It
*has* expanded %PATH% already, though if you do %NONEXISTENT% then you
get %NONEXISTENT% rather than a blank expansion in your command line.

(So it seems to expand *known* env vars, but not unknown ones.)

So if someone really felt like taking the time to write their own parser
instead of CommandLineToArgvW, then we could probably support glob
expansion, single quotes, etc.

I'm not willing to put in the time myself, but it is nice to know that
there is the option.

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

iEYEARECAAYFAkp8MD0ACgkQJdeBCYSNAANH8QCgz3okH2QxhMjLcyARDtc3xhaX
Jg0An1hpTeDWcrcBZlrO0jov79QqyUtw
=kY9Q
-----END PGP SIGNATURE-----



More information about the bazaar mailing list