You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
NO_COLOR implementation differs from the spec: also honors the variable if its value is empty #21198
should check for a NO_COLOR environment variable that, when present and not an empty string (regardless of its value), prevents the addition of ANSI color.
By contrast, PowerShell currently bases its behavior purely on the existence of this environment variable, and therefore also considers an empty variable (one whose value is the empty string) as requesting color opt-out.
# Run from a POSIX-like shell, such as Bash# Non-empty value: OK
NO_COLOR=1 pwsh -noprofile -c '$PSStyle.OutputRendering'# Empty value: !! Unexpectedly treated like a non-empty value.
NO_COLOR= pwsh -noprofile -c '$PSStyle.OutputRendering'
As an aside:
What the spec prescribes doesn't align with common practice for flag-like environment variables on Unix-like platforms: usually, for variables whose value doesn't matter, it is just the existence vs. non-existence that governs behavior.
The variant behavior does have one advantage, however: it allows calls such as NO_COLOR= foo ... (from POSIX-compatible shells) as an ad-hoc, child process-scoped opt-out out of non-coloring, which would otherwise not be possible, as this syntax doesn't support undefining (removing) environment variables ad hoc.
Expected behavior
PlainTextHost
That is:
the existence of NO_COLOR with a non-empty value should cause PowerShell to set $PSStyle.OutputRendering to PlainText
whereas an empty value should not.
Actual behavior
PlainTextPlainText
Error details
No response
Environment data
PowerShell 7.5.0-preview.1 on Unix-like platforms.
changed the title [-]`NO_COLOR` implementation differs from the spec.: also honors the variable if its value is empty[/-][+]`NO_COLOR` implementation differs from the spec: also honors the variable if its value is empty[/+]on Feb 11, 2024
Activity
rhubarb-geek-nz commentedon Feb 8, 2024
Given PowerShell is listed at NO_COLOR it would be good to have strict conformance with the specification and lead by example.
[-]`NO_COLOR` implementation differs from the spec.: also honors the variable if its value is empty[/-][+]`NO_COLOR` implementation differs from the spec: also honors the variable if its value is empty[/+]