-
-
Notifications
You must be signed in to change notification settings - Fork 273
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
Allow null values in environment variables #109
Comments
Specifically this may unlock the ability to unset an environment variable via CliWrap which is not currently possible. Consider this test program:
The program can distinguish between empty, unset and set env var BOOM. Here is a session demonstrating that
Note that
As far as I can tell this functionality is currently missing from CliWrap API. The user cannot remove the environment variable that is set globally. At best the user can set it to an empty value, which is not the same as removing it. If we allowed the Environment to have null string values, we could potentially interpret nulls as instructions to remove environment variables set globally. Note that https://docs.microsoft.com/en-us/dotnet/api/system.environment.setenvironmentvariable?view=net-5.0 currently treats empty values and nulls identically, and it treats them as instructions to remove. This is different from current behavior of CliWrap that treats empty values as explicit as-is values and passes them down. |
I think this actually requires dotnet/runtime#34446 to be fixed |
Sounds good to me. You can send a PR. |
We are seeing nullability warnings since
Command.EnvironmentVariables
is of type IReadOnlyDictionary<string, string> and not IReadOnlyDictionary<string, string?>.I would expect it to be the latter since it maintains consistency with CLR types:
Environment.SetEnvironmentVariable accepts a nullable string as its value and Environment.GetEnvironmentVariable returns a nullable string.
Are you interested in a PR to fix this?
The text was updated successfully, but these errors were encountered: