Skip to content

Write-Prompt 0.7.1 from PSGallery does not allow -ForegroundColor Black #470

Closed
@ayrtonmassey

Description

System Details

  • posh-git version/path: 0.7.1 from the PowerShell Gallery.
  • PowerShell version: 5.1.14393.1198
  • Git version: 2.7.1.windows.2
  • Operating system name and version:
    • Edition: Windows 10 Enterprise
    • Version: 1607
    • Build: 14393.1198

Issue Description

Write-Prompt checks to see if the $ForegroundColor parameter is empty by performing the check !$ForegroundColor. This works in all cases except when $ForegroundColor is [ConsoleColor]::Black, since Black evaluates to 0 and !0 == True.

The offending line is posh-git/src/GitPrompt.ps1:135:

function Write-Prompt($Object, $ForegroundColor = $null, $BackgroundColor = $null) {
    $s = $global:GitPromptSettings
    if ($s -and !$ForegroundColor) {
        $ForegroundColor = $s.DefaultForegroundColor
    }

I see that this was fixed by #454 on GitHub (the condition is now ($null -eq $ForegroundColor)) but the copy I obtained from PSGallery via Install-Module earlier today does not have this fix.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions