-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Description
Summary of the new feature / enhancement
PowerShell cannot natively write nor read blank environment variables, although all major OSes (including Windows) and all other popular shells support blank environment variables.
Blank environment variables are occasionally (albeit unintuitively) used as flags for certain applications. PowerShell not natively1 listing these environment variables makes them effectively hidden from the user (meaning behavioral changes in downstream processes that cannot be explained by PowerShell's view of the environment variables). PowerShell not writing these environment variables means that a user cannot opt-in2 to behaviors triggered by them.
The reason for PowerShell's lack of support for blank environment variables seems to be due to a combination of historical lack of support in Windows3 and the current lack of support in .NET's System.Environment
class4.
Proposed technical implementation details (optional)
No response
Footnotes
-
PowerShell does display blank environment variables via
[System.Environment]::GetEnvironmentVariables(…)
, but this lacks discoverability and is not documented for this use case in PowerShell. There is also zero reciprocal capability to create such environment variables. ↩ -
Not idiomatically, anyway. When a downstream app recommends setting a blank environment variable for a particular use case, they tend to literally mean it must exist but also they reserve the right to have it support meaningful non-blank values in a future update. ↩
-
As of Windows 7,
cmd
and PowerShell can set blank environment variables withsetx
- but this has usability limitations w.r.t. PowerShell workflows and does not apply to PowerShell outside of Windows. ↩ -
System.Environment
could be made to support blank environment variables - see https://github.com/dotnet/runtime/issues/50554. ↩