[issue444582] Finding programs in PATH, adding shutil.which
Weeble
report at bugs.python.org
Mon Nov 28 13:06:08 CET 2011
Weeble <clockworksaint at gmail.com> added the comment:
I'm not sure what rules are used by Windows to process the PATH string, but I think they are similar to the rules used to parse the command-line into argv in a C/C++ program: http://msdn.microsoft.com/en-us/library/17w5ykft.aspx
I have tested various arrangements of double-quotes in path elements. It appears the quotes can appear anywhere, not just at the start and end of entries. As far as I can tell, *all* they do is toggle the interpretation of the semicolon character between a separator and a character in the directory path. Note in particular: quotes may surround an entire path, segments of a path, fragments of segments of a path, or even may be completely empty. Any number of quotes can appear in a single path entry. There doesn't even need to be an even number of quotes - it seems that an odd number of quotes are treated the same as if a final quote was appended to the very end of the PATH string.
Running my attached test batch file, I see these results:
c:\Users\weeble>pathtest
PATH=
FAIL
PATH=c:\Users\weeble\foo;bar
FAIL
PATH=c:\Users\weeble\"foo;bar"
SUCCESS
PATH="c:\Users\weeble\foo;bar"
SUCCESS
PATH=c:\Users\weeble\"foo;"bar
SUCCESS
PATH=c:\Users\weeble\foo";"bar
SUCCESS
PATH=c:\Users\weeble\""foo";"bar""
SUCCESS
PATH=
FAIL
PATH=c:\Users\weeble\foo";bar
SUCCESS
----------
nosy: +weeble
Added file: http://bugs.python.org/file23797/pathtest.bat
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue444582>
_______________________________________
More information about the Python-bugs-list
mailing list