Apparently overwrite should report success

This commit is contained in:
Niklas Larsson 2020-06-16 13:58:49 +02:00
parent 24715a8fd0
commit 2e8f618f00
3 changed files with 10 additions and 2 deletions

View File

@ -76,7 +76,7 @@ void win32_sleep(int ms) {
int win32_modenv(const char* name, const char* value, int overwrite) {
char buffer[2000];
if (!overwrite && getenv(name)) return -1;
if (!overwrite && getenv(name)) return 0;
if (strlen(name) + strlen(value) > 1998) return -1;
sprintf(buffer, "%s=%s", name, value);
return putenv(buffer);

View File

@ -11,8 +11,14 @@ main = do
putStrLn str
ok <- setEnv "HELLO" "HO" False
printLn ok
Just str <- getEnv "HELLO"
| Nothing => pure ()
putStrLn str
ok <- setEnv "HELLO" "EH" True
printLn ok
Just str <- getEnv "HELLO"
| Nothing => pure ()
putStrLn str
ok <- unsetEnv "HELLO"
printLn ok
Just str <- getEnv "HELLO"

View File

@ -1,7 +1,9 @@
True
HI
False
True
HI
True
EH
True
Nothing there
1/1: Building Envy (Envy.idr)