os.findExe: do not return binaries in the cwd

This commit is contained in:
Araq
2017-09-01 19:31:27 +02:00
parent 85dc40c121
commit a43eae8e6c

View File

@@ -141,7 +141,12 @@ proc findExe*(exe: string, followSymlinks: bool = true;
## meets the actual file. This behavior can be disabled if desired.
for ext in extensions:
result = addFileExt(exe, ext)
if existsFile(result): return
if existsFile(result):
# on Posix ensure we do not yield binaries in the cwd:
when defined(posix):
if isAbsolute(result): return
else:
return
var path = string(getEnv("PATH"))
for candidate in split(path, PathSep):
when defined(windows):