better fix for #4497

This commit is contained in:
Andreas Rumpf 2016-07-19 11:21:14 +02:00
commit ab9e44dc96

View file

@ -559,9 +559,8 @@ when declared(getEnv) or defined(nimscript):
when not defined(windows) and declared(os): when not defined(windows) and declared(os):
proc checkSymlink(path: string): bool = proc checkSymlink(path: string): bool =
var rawInfo: Stat var rawInfo: Stat
if lstat(path, rawInfo) < 0'i32: if lstat(path, rawInfo) < 0'i32: result = false
raiseOSError(osLastError()) else: result = S_ISLNK(rawInfo.st_mode)
S_ISLNK(rawInfo.st_mode)
proc findExe*(exe: string, followSymlinks: bool = true): string {. proc findExe*(exe: string, followSymlinks: bool = true): string {.
tags: [ReadDirEffect, ReadEnvEffect, ReadIOEffect].} = tags: [ReadDirEffect, ReadEnvEffect, ReadIOEffect].} =
@ -584,7 +583,7 @@ when declared(getEnv) or defined(nimscript):
if existsFile(x): if existsFile(x):
when not defined(windows) and declared(os): when not defined(windows) and declared(os):
while followSymlinks: # doubles as if here while followSymlinks: # doubles as if here
if x.isAbsolute and x.checkSymlink: if x.checkSymlink:
var r = newString(256) var r = newString(256)
var len = readlink(x, r, 256) var len = readlink(x, r, 256)
if len < 0: if len < 0: