Mercurial > public > mercurial-scm > hg
diff mercurial/util.py @ 4488:62019c4427e3
Introduce find_exe. Use instead of find_in_path for programs.
The behaviour of find_in_path was broken for config options containing
path names, because it always searched the given path, even when not
necessary. The find_exe function is more polite: if the name passed
to it contains a path component, it just returns it.
author | Bryan O'Sullivan <bos@serpentine.com> |
---|---|
date | Sun, 27 May 2007 14:26:54 -0700 |
parents | 439b1c35348a |
children | 0026ccc2bf23 |
line wrap: on
line diff
--- a/mercurial/util.py Sun May 27 13:50:59 2007 -0700 +++ b/mercurial/util.py Sun May 27 14:26:54 2007 -0700 @@ -1087,6 +1087,18 @@ return p_name return default +def find_exe(name, default=None): + '''find path of an executable. + if name contains a path component, return it as is. otherwise, + use normal executable search path.''' + + if os.sep in name: + # don't check the executable bit. if the file isn't + # executable, whoever tries to actually run it will give a + # much more useful error message. + return name + return find_in_path(name, os.environ.get('PATH', ''), default=default) + def _buildencodefun(): e = '_' win_reserved = [ord(x) for x in '\\:*?"<>|']