[Distutils] install w/o build, spaces in directory names

Greg Ward gward@python.net
Mon, 14 Feb 2000 18:49:27 -0500

On 11 February 2000, Thomas Heller said:
> I tried quoting the parameters for _spawn_nt in the following way,
> which worked for me (after changing some paths to include spaces,
> which I usually avoid). Not sure if cmd[0] should also be quoted:

Well, this patch looks better than nothing.  But I have a couple
questions for the Windows crowd:

  * when I use 'os.spawnv()', just how many levels of software are
    involved (C library? kernel? the child program being run?) in
    parsing the command line -- i.e. in splitting the
    Python-list-of-strings up into the argv[] seen by the child program?
    In other words, whose rules do we have to work with here to properly
    handle filenames with spaces in them?
  * regardless of who's involved, what *are* the rules?  Ie. what
    characters in a command-line argument will cause that argument to
    need quoting?  What are the allowed quote characters?  How
    do you deal with arguments that contain the quote characters (ie.
    what if I had a directory named
         Program "Files"

  * is any of this standard or documented, or does it vary from
    application to application?

I'll wait to hear some feedback on this before I accept Thomas' patch -- 
I'm just superstitious that it can't be *this* simple:

    def _quote_if_needed (arg):
        """Obscure quoting command line arguments on NT.
           Simply quote every argument which contains blanks"""
        if string.find (arg, ' ') == -1:
            return arg
        return '"%s"' % arg

(BTW Thomas, your patch was backwards.  This is easy to workaround -- I
just have to run "patch -R" -- but it's easier to read patches if you
say "diff <old_file> <new_file>" rather than "diff <new_file>
<old_file>", which is what I suspect you did.)

Thanks --

Greg Ward - just another Python hacker                  gward@python.net
Disclaimer: All rights reserved. Void where prohibited. Limit 1 per customer.