Skip to content

Commit

Permalink
Fix put_env inconsistency between platforms HaxeFoundation#229
Browse files Browse the repository at this point in the history
* When `put_env` is called with an empty string for `v`, it now unsets
the variable on all platforms, not just windows
  • Loading branch information
tobil4sk committed Aug 26, 2021
1 parent 1df580c commit 026d92f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion libs/std/sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,14 @@ static value put_env( value e, value v ) {
if( putenv(val_string(buffer_to_string(b))) != 0 )
neko_error();
#else
char *val;
val_check(e,string);
val_check(v,string);
if( setenv(val_string(e),val_string(v),1) != 0 )
val = val_string(v);
if( val[0] == '\0' ) {
if( unsetenv(val_string(e)) != 0 )
neko_error();
} else if( setenv(val_string(e),val,1) != 0 )
neko_error();
#endif
return val_true;
Expand Down

0 comments on commit 026d92f

Please sign in to comment.