8000 Read & Write Blank (`""`) Environment Variables · Issue #21186 · PowerShell/PowerShell · GitHub
[go: up one dir, main page]

Skip to content
Read & Write Blank ("") Environment Variables #21186
@brucificus

Description

@brucificus

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

  1. 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.

  2. 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.

  3. As of Windows 7, cmd and PowerShell can set blank environment variables with setx - but this has usability limitations w.r.t. PowerShell workflows and does not apply to PowerShell outside of Windows.

  4. System.Environment could be made to support blank environment variables - see https://github.com/dotnet/runtime/issues/50554.

Metadata

Metadata

Assignees

Labels

Breaking-Changebreaking change that may affect usersIssue-Enhancementthe issue is more of a feature request than a bugWG-Enginecore PowerShell engine, interpreter, and runtimeWG-ReviewedA Working Group has reviewed this and made a recommendationWaiting - DotNetCorewaiting on a fix/change in .NET

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0