-
-
Notifications
You must be signed in to change notification settings - Fork 665
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No consistent way to unset environment variable #10395
Comments
The first thing to investigate here is if platforms generally allow the distinction between the variable not being set (equivalent to |
The targets in the first and second category do make this distinction. Neko and Eval do not, however they give an error when trying to do |
I did a bit more investigating, turns out I was experiencing an issue with the Haxe server and Eval is part of the first group as well. (ie it does indeed distinguish between the two). |
Correction, because I think I slightly misunderstood the question: The rest of the targets also can tell the difference. |
Then |
I would argue that it makes more sense to create a separate function for unsetting the variable. On most targets, as setting to function putEnv(name:String, value:Null<String>) {
if (value == null)
someApi.unsetEenv(name);
else
someApi.putEnv(name, value);
} In this case, I would argue that it wouldn't really be a convenience function, as the two functions would be for separate API calls and really do different things. Also, putting them together as one function introduces an unnecessary branch in the code, as the user knows when they call the function whether they are doing it to set a value or delete the variable, so there is no reason for the function to have to figure that out again. I hope my opinion makes sense, it might be nitpicking but also it would require specifically changing the type of the value to be I did testing on Windows, and all targets apart from Python and php (I haven't tested lua though) delete the variable if I'm happy to work on this once it's decided whether there should be a separate function or not. |
After more consideration I saw why it's better to not change the api, because it would come with a lot of required changes in a bunch of other repositories. Also if it's already been implemented on a couple targets (namely hl and php) then might as well make sure it works everywhere. So anyway, I made a PR for this: #10402 |
Currently, some targets have ways of unsetting environment variables, while others do not. So, after doing:
There is no consistent way to remove the environment variable. Different targets have different behaviours, listed below.
Sys.putEnv("VARIABLE", null);
:Sys.putEnv("VARIABLE", "");
on Windows:It might be best to have a separate function, for example
Sys.unsetEnv("VARIABLE");
, that handles this.It would also be good if
Sys.putEnv("VARIABLE", null);
andSys.putEnv("VARIABLE", "");
worked consistently between platforms, however, this is more difficult because some platforms may have these behaviours because of their APIs. It also requires an agreement on the behaviour of the function in these two cases.The text was updated successfully, but these errors were encountered: