~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: Gordon Tyler
  • Date: 2012-02-28 04:58:14 UTC
  • mto: (6437.23.20 2.5)
  • mto: This revision was merged to the branch mainline in revision 6493.
  • Revision ID: gordon@doxxx.net-20120228045814-nab581dyd7ie5u14
Backport of fix for bug 939605 to bzr 2.5 series.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2473
2473
    :param name: The base name of the executable.
2474
2474
    :return: The path to the executable found or None.
2475
2475
    """
2476
 
    path = os.environ.get('PATH')
2477
 
    if path is None:
2478
 
        return None
2479
 
    path = path.split(os.pathsep)
2480
2476
    if sys.platform == 'win32':
2481
2477
        exts = os.environ.get('PATHEXT', '').split(os.pathsep)
2482
2478
        exts = [ext.lower() for ext in exts]
2488
2484
            exts = [ext]
2489
2485
    else:
2490
2486
        exts = ['']
2491
 
    for ext in exts:
2492
 
        for d in path:
2493
 
            f = os.path.join(d, name) + ext
2494
 
            if os.access(f, os.X_OK):
2495
 
                return f
 
2487
    path = os.environ.get('PATH')
 
2488
    if path is not None:
 
2489
        path = path.split(os.pathsep)
 
2490
        for ext in exts:
 
2491
            for d in path:
 
2492
                f = os.path.join(d, name) + ext
 
2493
                if os.access(f, os.X_OK):
 
2494
                    return f
 
2495
    if sys.platform == 'win32':
 
2496
        app_path = win32utils.get_app_path(name)
 
2497
        if app_path != name:
 
2498
            return app_path
2496
2499
    return None
2497
2500
 
2498
2501