Bug 1384731 - Allow which to find files in paths that use the ~ character to represent the home directory
MozReview-Commit-ID: FeV1k9Piwuo
--- a/third_party/python/which/which.py
+++ b/third_party/python/which/which.py
@@ -193,17 +193,18 @@ def whichgen(command, path=None, verbose
for i in range(len(path)):
dirName = path[i]
# On windows the dirName *could* be quoted, drop the quotes
if sys.platform.startswith("win") and len(dirName) >= 2\
and dirName[0] == '"' and dirName[-1] == '"':
dirName = dirName[1:-1]
for ext in ['']+exts:
absName = os.path.abspath(
- os.path.normpath(os.path.join(dirName, command+ext)))
+ os.path.expanduser(
+ os.path.normpath(os.path.join(dirName, command+ext))))
if os.path.isfile(absName):
if usingGivenPath:
fromWhere = "from given path element %d" % i
elif not sys.platform.startswith("win"):
fromWhere = "from PATH element %d" % i
elif i == 0:
fromWhere = "from current directory"
else: