mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-18 17:08:32 +00:00
Make getEnv case insensitive on Windows (#9722)
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
when not declared(os):
|
||||
{.error: "This is an include file for os.nim!".}
|
||||
|
||||
from parseutils import skipIgnoreCase
|
||||
|
||||
proc c_getenv(env: cstring): cstring {.
|
||||
importc: "getenv", header: "<stdlib.h>".}
|
||||
proc c_putenv(env: cstring): cint {.
|
||||
@@ -91,7 +93,10 @@ proc findEnvVar(key: string): int =
|
||||
getEnvVarsC()
|
||||
var temp = key & '='
|
||||
for i in 0..high(environment):
|
||||
if startsWith(environment[i], temp): return i
|
||||
when defined(windows):
|
||||
if skipIgnoreCase(environment[i], temp) == len(temp): return i
|
||||
else:
|
||||
if startsWith(environment[i], temp): return i
|
||||
return -1
|
||||
|
||||
proc getEnv*(key: string, default = ""): TaintedString {.tags: [ReadEnvEffect].} =
|
||||
|
||||
Reference in New Issue
Block a user