From 79934b9d6817e0d51b13ef67fd2cab556f9f7460 Mon Sep 17 00:00:00 2001 From: Grzegorz Adam Hankiewicz Date: Mon, 16 Mar 2015 22:01:56 +0100 Subject: Expands tildes for entries in $PATH when looking for a binary. --- lib/pure/os.nim | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/pure/os.nim b/lib/pure/os.nim index 82d6177e1..63dcde4e3 100644 --- a/lib/pure/os.nim +++ b/lib/pure/os.nim @@ -1863,16 +1863,18 @@ proc getFileSize*(file: string): BiggestInt {.rtl, extern: "nos$1", close(f) else: raiseOSError(osLastError()) +proc expandTilde*(path: string): string {.tags: [ReadEnvEffect].} + proc findExe*(exe: string): string {.tags: [ReadDirEffect, ReadEnvEffect].} = ## Searches for `exe` in the current working directory and then ## in directories listed in the ``PATH`` environment variable. ## Returns "" if the `exe` cannot be found. On DOS-like platforms, `exe` - ## is added an ``.exe`` file extension if it has no extension. + ## is added the `ExeExt <#ExeExt>`_ file extension if it has none. result = addFileExt(exe, os.ExeExt) if existsFile(result): return var path = string(os.getEnv("PATH")) for candidate in split(path, PathSep): - var x = candidate / result + var x = expandTilde(candidate) / result if existsFile(x): return x result = "" -- cgit 1.4.1-2-gfad0 From 1320efcf90021fe8b60eb27cea046f837b15baa6 Mon Sep 17 00:00:00 2001 From: Grzegorz Adam Hankiewicz Date: Tue, 17 Mar 2015 20:07:20 +0100 Subject: Excludes windows platfrom from $PATH tilde expansion. Refs #2358. --- lib/pure/os.nim | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/pure/os.nim b/lib/pure/os.nim index 63dcde4e3..f53abe81d 100644 --- a/lib/pure/os.nim +++ b/lib/pure/os.nim @@ -1874,7 +1874,10 @@ proc findExe*(exe: string): string {.tags: [ReadDirEffect, ReadEnvEffect].} = if existsFile(result): return var path = string(os.getEnv("PATH")) for candidate in split(path, PathSep): - var x = expandTilde(candidate) / result + when defined(windows): + var x = candidate / result + else: + var x = expandTilde(candidate) / result if existsFile(x): return x result = "" -- cgit 1.4.1-2-gfad0