Bug 1384731 - Allow which to find files in paths that use the ~ character to represent the home directory draft
authorKirk Steuber <ksteuber@mozilla.com>
Wed, 26 Jul 2017 15:43:07 -0600
changeset 616203 3cc391eb0bc76cdba78d1678923a804b1346d370
parent 615935 388d81ed93fa640f91d155f36254667c734157cf
child 639427 27bfb5e39ed6f8698c412290e2b6cf69a4e057b0
push id70635
push userbmo:ksteuber@mozilla.com
push dateWed, 26 Jul 2017 21:44:43 +0000
bugs1384731
milestone56.0a1
Bug 1384731 - Allow which to find files in paths that use the ~ character to represent the home directory MozReview-Commit-ID: FeV1k9Piwuo
third_party/python/which/which.py
--- 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: