diff options
author | Stuart Rackham <srackham@methods.co.nz> | 2009-10-30 13:40:57 +1300 |
---|---|---|
committer | Stuart Rackham <srackham@methods.co.nz> | 2009-10-30 13:40:57 +1300 |
commit | 38d22ff4deb5f7a77d7360f42cea8900279ec394 (patch) | |
tree | 648362d4034d2a8ac71ea877c2642ae0c7571719 | |
parent | 4f6ef29080aca4d18cbe4509b42d9c1bb9a2359b (diff) | |
download | asciidoc-38d22ff4deb5f7a77d7360f42cea8900279ec394.tar.gz |
FIXED: Error occured if a directory in current path with same name as
executable.
-rwxr-xr-x | a2x.py | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -107,6 +107,9 @@ class AttrDict(dict): def __setstate__(self,value): for k,v in value.items(): self[k]=v +def isexecutable(file_name): + return os.path.isfile(file_name) and os.access(file_name, os.X_OK) + def find_executable(file_name): ''' Search for executable file_name in the system PATH. @@ -115,13 +118,13 @@ def find_executable(file_name): def _find_executable(file_name): if os.path.split(file_name)[0] != '': # file_name includes directory so don't search path. - if not os.access(file_name, os.X_OK): + if not isexecutable(file_name): return None else: return file_name for p in os.environ.get('PATH', os.defpath).split(os.pathsep): f = os.path.join(p, file_name) - if os.access(f, os.X_OK): + if isexecutable(f): return os.path.realpath(f) return None if os.name == 'nt' and os.path.splitext(file_name)[1] == '': |