[Buildbot-devel] win32 create process info

Brian Warner warner-buildbot at lothar.com
Tue Apr 26 20:35:38 UTC 2005


> The correct command line is "cmd.exe /c ..." (equivalent to sh -e) which
> means /c needs to be added also. I don't know of any downside to this; cmd
> loads its environment from the registry, the same as all other windows
> programs.

So, one further question before I add this. At the moment, our
process-spawning code looks like this:

        if type(self.command) in types.StringTypes:
            if runtime.platformType  == 'win32':
                argv = [os.environ['COMSPEC'], '/c', self.command]
            else:
                # for posix, use /bin/sh. for other non-posix, well, doesn't
                # hurt to try
                argv = ['/bin/sh', '-c', self.command]
        else:
            argv = self.command

I'm assuming that os.environ['COMSPEC'] is generally equal to "cmd.exe". If I
change this code to:

        if type(self.command) in types.StringTypes:
            if runtime.platformType  == 'win32':
                argv = [os.environ['COMSPEC'], '/c', self.command]
            else:
                # for posix, use /bin/sh. for other non-posix, well, doesn't
                # hurt to try
                argv = ['/bin/sh', '-c', self.command]
        else:
            if runtime.platformType  == 'win32':
                argv = [os.environ['COMSPEC'], '/c'] + list(self.command)
            else:
                argv = self.command

then will it work for a command that has spaces in it? The /bin/sh route
re-parses the argv elements and splits on spaces.. does cmd.exe do the same?

thanks,
 -Brian




More information about the devel mailing list