Skip to content
This repository
Browse code

Fix errors with Set-PSDebug -Strict

Set-PSDebug -Strict will complain if any variable is used before it is
initialized. This was happening with the $sw variable.

The practical
effect of this bug was that the nice posh-git prompt would disappear if
"Set-PSDebug -Strict" was ever called in a PowerShell session.
  • Loading branch information...
commit c4ac7bff8ddb96480778f3cf2eb8b7a5218c4a35 1 parent fd36b16
Adam Roben authored

Showing 1 changed file with 5 additions and 1 deletion. Show diff stats Hide diff stats

  1. 6  GitUtils.ps1
6  GitUtils.ps1
@@ -82,7 +82,11 @@ function Get-GitStatus($gitDir = (Get-GitDirectory)) {
82 82
     $enabled = (-not $settings) -or $settings.EnablePromptStatus
83 83
     if ($enabled -and $gitDir)
84 84
     {
85  
-        if($settings.Debug) { $sw = [Diagnostics.Stopwatch]::StartNew(); Write-Host '' }
  85
+        if($settings.Debug) {
  86
+            $sw = [Diagnostics.Stopwatch]::StartNew(); Write-Host ''
  87
+        } else {
  88
+            $sw = $null
  89
+        }
86 90
         $branch = $null
87 91
         $aheadBy = 0
88 92
         $behindBy = 0

0 notes on commit c4ac7bf

Please sign in to comment.
Something went wrong with that request. Please try again.