This commit is contained in:
Andreas Rumpf 2018-02-02 17:34:54 +01:00
commit 4f9ae61695

View file

@ -139,10 +139,15 @@ proc findExe*(exe: string, followSymlinks: bool = true;
## is added the `ExeExts <#ExeExts>`_ file extensions if it has none. ## is added the `ExeExts <#ExeExts>`_ file extensions if it has none.
## If the system supports symlinks it also resolves them until it ## If the system supports symlinks it also resolves them until it
## meets the actual file. This behavior can be disabled if desired. ## meets the actual file. This behavior can be disabled if desired.
template checkCurrentDir() =
for ext in extensions: for ext in extensions:
result = addFileExt(exe, ext) result = addFileExt(exe, ext)
if existsFile(result): return if existsFile(result): return
var path = string(getEnv("PATH")) when defined(posix):
if '/' in exe: checkCurrentDir()
else:
checkCurrentDir()
let path = string(getEnv("PATH"))
for candidate in split(path, PathSep): for candidate in split(path, PathSep):
when defined(windows): when defined(windows):
var x = (if candidate[0] == '"' and candidate[^1] == '"': var x = (if candidate[0] == '"' and candidate[^1] == '"':