summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorGrzegorz Adam Hankiewicz <gradha@imap.cc>2015-03-16 22:01:56 +0100
committerGrzegorz Adam Hankiewicz <gradha@imap.cc>2015-03-16 22:01:56 +0100
commit79934b9d6817e0d51b13ef67fd2cab556f9f7460 (patch)
tree055efb25f73c1754b699e5ce8bd5edaa12121e88
parent1838ea2db4bbcb077d2b73d3eddbbb6554b294de (diff)
downloadNim-79934b9d6817e0d51b13ef67fd2cab556f9f7460.tar.gz
Expands tildes for entries in $PATH when looking for a binary.
-rw-r--r--lib/pure/os.nim6
1 files 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 = ""