-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
'ProcessStartInfo.EnvironmentVariables ["FOO"] = null' launches with empty environment variable #34446
Comments
/cc @stephentoub |
There is a difference between mono and .netcore with regards to environment variables when launching processes. For the following example: process.StartInfo.EnvironmentVariables ["FOO"] = null; .netcore will launch the process with an empty FOO variable, while mono will launch the process with no FOO variable set. So unstead remove the variable from the collection of environment variables (this works fine even if the collection doesn't contain the variable). Ref: dotnet/runtime#34446
This is the result of: runtime/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Unix.cs Line 606 in a4a1c8b
On Windows it is implemented as: runtime/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Windows.cs Lines 904 to 910 in a4a1c8b
So on Windows, it has a similar behavior. If you use
The consistency would be nice. It would also be a breaking change. |
Would it really? If you in Windows execute To my understanding, that establishes it's in fact impossible, using the Win32 API, to have an environment variable without a value, and I'm willing to go out on a limb and guess the POSIX spec says the same thing. If extending your quoted code to include the leading comment, we see even there that a value is expected: runtime/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Windows.cs Line 902 in a4a1c8b
So it seems that however we view it, from logic, from customer complaint, from Win32 and even from the documented intention of the source code in question itself, and likely also from POSIX and any concievable shell on any platform, past, present or future, this is a bug. It seems odd to oppose fixing such a bug, using unsubstantiated FUD as the only argument. If the claim could be substantiated my position about fixing this bug would change, but I honestly don't think you can. I don't think anyone, anywehere, could be so... sick, as to depends on such a logic-defying behaviour, unless they were using it for malware. |
@tamlin-mike both Windows and Linux can have environment variables which are set to an empty string. It's important to identify breaking changes even when the suggested behavior is meaningful. |
There is a difference between mono and .netcore with regards to environment variables when launching processes. For the following example: process.StartInfo.EnvironmentVariables ["FOO"] = null; .netcore will launch the process with an empty FOO variable, while mono will launch the process with no FOO variable set. So unstead remove the variable from the collection of environment variables (this works fine even if the collection doesn't contain the variable). Ref: dotnet/runtime#34446
There is a difference between mono and .netcore with regards to environment variables when launching processes. For the following example: process.StartInfo.EnvironmentVariables ["FOO"] = null; .netcore will launch the process with an empty FOO variable, while mono will launch the process with no FOO variable set. So unstead remove the variable from the collection of environment variables (this works fine even if the collection doesn't contain the variable). Ref: dotnet/runtime#34446
There is a difference between mono and .netcore with regards to environment variables when launching processes. For the following example: process.StartInfo.EnvironmentVariables ["FOO"] = null; .netcore will launch the process with an empty FOO variable, while mono will launch the process with no FOO variable set. So unstead remove the variable from the collection of environment variables (this works fine even if the collection doesn't contain the variable). Ref: dotnet/runtime#34446
) There is a difference between mono and .netcore with regards to environment variables when launching processes. For the following example: process.StartInfo.EnvironmentVariables ["FOO"] = null; .netcore will launch the process with an empty FOO variable, while mono will launch the process with no FOO variable set. So unstead remove the variable from the collection of environment variables (this works fine even if the collection doesn't contain the variable). Ref: dotnet/runtime#34446
) There is a difference between mono and .netcore with regards to environment variables when launching processes. For the following example: process.StartInfo.EnvironmentVariables ["FOO"] = null; .netcore will launch the process with an empty FOO variable, while mono will launch the process with no FOO variable set. So unstead remove the variable from the collection of environment variables (this works fine even if the collection doesn't contain the variable). Ref: dotnet/runtime#34446
Repro:
Execute:
$ dotnet run | grep FOO FOO=
Try with mono:
Allowing setting an environment variable to null to remove it would match the behavior of the Environment class, where you're supposed to
Environment.SetEnvironmentVariable ("FOO", null);
to delete that variable.The text was updated successfully, but these errors were encountered: