summary refs log tree commit diff stats
path: root/tools
diff options
context:
space:
mode:
authorgenotrance <dev@genotrance.com>2018-05-02 12:16:44 -0500
committerAndreas Rumpf <rumpf_a@web.de>2018-05-02 19:16:44 +0200
commit452321874d47f33404b68e4624929b7faf02555a (patch)
tree2e1c2b0fcdedf38b8e37124b6698eea8f0f123a4 /tools
parent21cbf438ceae059f528cfd28bbeec5b637e210ac (diff)
downloadNim-452321874d47f33404b68e4624929b7faf02555a.tar.gz
Fixes for #7747 - finish.exe issues (#7748)
Diffstat (limited to 'tools')
-rw-r--r--tools/finish.nim31
1 files changed, 16 insertions, 15 deletions
diff --git a/tools/finish.nim b/tools/finish.nim
index 2681f7ccf..b5ef78b65 100644
--- a/tools/finish.nim
+++ b/tools/finish.nim
@@ -52,14 +52,17 @@ when defined(windows):
   proc askBool(m: string): bool =
     stdout.write m
     while true:
-      let answer = stdin.readLine().normalize
-      case answer
-      of "y", "yes":
-        return true
-      of "n", "no":
-        return false
-      else:
-        echo "Please type 'y' or 'n'"
+      try:
+        let answer = stdin.readLine().normalize
+        case answer
+        of "y", "yes":
+          return true
+        of "n", "no":
+          return false
+        else:
+          echo "Please type 'y' or 'n'"
+      except EOFError:
+        quit(1)
 
   proc askNumber(m: string; a, b: int): int =
     stdout.write m
@@ -99,10 +102,6 @@ when defined(windows):
 
   proc addToPathEnv*(e: string) =
     var p = tryGetUnicodeValue(r"Environment", "Path", HKEY_CURRENT_USER)
-    if p.len == 0:
-      p = tryGetUnicodeValue(
-        r"SYSTEM\CurrentControlSet\Control\Session Manager\Environment",
-        "Path", HKEY_LOCAL_MACHINE)
     let x = if e.contains(Whitespace): "\"" & e & "\"" else: e
     if p.len > 0:
       p.add ";"
@@ -189,8 +188,10 @@ when defined(windows):
 proc main() =
   when defined(windows):
     let desiredPath = expandFilename(getCurrentDir() / "bin")
-    let p = getUnicodeValue(r"Environment", "Path",
-      HKEY_CURRENT_USER)
+    let p = tryGetUnicodeValue(r"Environment", "Path",
+      HKEY_CURRENT_USER) & ";" & tryGetUnicodeValue(
+        r"System\CurrentControlSet\Control\Session Manager\Environment", "Path",
+        HKEY_LOCAL_MACHINE)
     var alreadyInPath = false
     var mingWchoices: seq[string] = @[]
     var incompat: seq[string] = @[]
@@ -199,7 +200,7 @@ proc main() =
       let y = try: expandFilename(if x[0] == '"' and x[^1] == '"':
                                     substr(x, 1, x.len-2) else: x)
               except: ""
-      if y == desiredPath: alreadyInPath = true
+      if y.cmpIgnoreCase(desiredPath) == 0: alreadyInPath = true
       if y.toLowerAscii.contains("mingw"):
         if dirExists(y):
           if checkGccArch(y): mingWchoices.add y