[Distutils] distutils - Filenames/Pathnames with spaces under WinNT
Greg Ward
gward@python.net
Thu, 9 Mar 2000 20:00:58 -0500
On 09 March 2000, Jonathan M. Gilligan said:
> I'm new on this list, so please forgive me if I'm treading on familiar
> ground, but I didn't see this issue raised when I browsed through the last
> month or so of archives.
>
> Distutils for Windows NT,9x,2K seems to have a big hole in the way it forms
> command-lines for the compiler and friends: it doesn't account for the fact
> that filenames and pathnames may have spaces in them and thus may need to
> be quoted on the command-line passed to external tools (compiler, linker).
Yeah, that did come up not *too* long ago. It was during a big flurry
of activity on the Windows support, so no surprise that you missed it.
Bottom line: Thomas Heller submitted a patch several weeks ago, and I
*finally* got around to applying it this weekend. It's in the CVS
version.
> I started hacking at the msvccompiler.py source to put quotes around
> filenames passed as arguments, but then realized that it would probably be
> better to implement a "wrapfilename(fname)" method in the ccompiler class
> and then subclass it appropriately for *ix (return fname) and WinNT (return
> '"%s"' % fname). Then every time a filename or path gets added to a
> command-line it must be processed with wrapfilename(). For instance:
>
> inputOpt = fileOpt + wrapfilename(srcFile)
>
> Does this sound like a reasonable approach? Am I missing a boat somewhere?
But what about arguments with spaces in them that *aren't* filenames?
(And what about spawning programs on Windows *other* than the
compiler/linker? Granted that's not happening right now in Distutils,
but who knows what'll happen in the future?)
> Alternately, one could modify _spawn_nt to wrap each of its arguments in
> double-quotes, but that seems potentially more problematic (Some programs
> may not transparently discard quotation marks on command-line arguments.
> Consider the behavior of the find command.).
That's exactly what we ended up doing. Your point about some programs
not dealing with quote characters is a bit unsettling, though. *sigh*
"Those who do not learn from Unix are doomed to reinvent it -- badly."
Greg
--
Greg Ward - Unix weenie gward@python.net
http://starship.python.net/~gward/
Earn cash in your spare time -- blackmail your friends!