Skip to content
This repository has been archived by the owner on Jul 19, 2023. It is now read-only.

Commit

Permalink
Merge pull request #96 from keisukefukuda/fix/unescaped_dirpath
Browse files Browse the repository at this point in the history
fix crash when dirpath contains special character
  • Loading branch information
keisukefukuda committed Sep 4, 2018
2 parents ae54bd6 + 515a115 commit f675474
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion bin/autodiscover.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@
_quiet = None


try:
_glob_escape = glob.escape
except AttributeError:
# Python <3.4
def _glob_escape(pathname):
pat = re.compile(r'([[?*])')
return pat.sub(r'[\1]', pathname)


def printv(s):
if _verbose:
sys.stderr.write(s + "\n")
Expand Down Expand Up @@ -78,7 +87,7 @@ def list_mpiexec(dirpath):
* Otherwise, one is randomly chosen
"""

lst = glob.glob(os.path.join(dirpath, 'bin', '*mpiexec*'))
lst = glob.glob(os.path.join(_glob_escape(dirpath), 'bin', '*mpiexec*'))
link_rel = {}

# As an exception, we need to exclude binaries like
Expand Down

0 comments on commit f675474

Please sign in to comment.