Skip to content

fix(pwsh): repair profile load tracer — empty-List truthiness swallow…#74

Merged
Gerrrt merged 1 commit into
mainfrom
fix/profile-load-tracer
Jul 1, 2026
Merged

fix(pwsh): repair profile load tracer — empty-List truthiness swallow…#74
Gerrrt merged 1 commit into
mainfrom
fix/profile-load-tracer

Conversation

@Gerrrt

@Gerrrt Gerrrt commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

…ed the trace

Two PowerShell collection-semantics bugs left DOTFILES_PROFILE_TRACE=1 with no table:

  • $x = if (...) { [List]::new() } emits the empty list through the pipeline, which enumerates it to nothing, so $global:DotfilesTrace ended up $null. Assign the List directly via if/else instead.
  • Add-DotfilesTrace guarded with if ($global:DotfilesTrace), but an empty List is falsy in PowerShell, so the first .Add() never fired and the list stayed empty forever. Use an explicit $null -ne check.

With both fixed, the sorted load-trace table prints as intended.

…ed the trace

Two PowerShell collection-semantics bugs left DOTFILES_PROFILE_TRACE=1 with no
table:

- `$x = if (...) { [List]::new() }` emits the empty list through the pipeline,
  which enumerates it to nothing, so $global:DotfilesTrace ended up $null.
  Assign the List directly via if/else instead.
- Add-DotfilesTrace guarded with `if ($global:DotfilesTrace)`, but an empty
  List is falsy in PowerShell, so the first .Add() never fired and the list
  stayed empty forever. Use an explicit `$null -ne` check.

With both fixed, the sorted load-trace table prints as intended.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 1, 2026 20:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes the PowerShell profile “load tracer” so DOTFILES_PROFILE_TRACE=1 reliably produces the intended sorted trace table by correcting two PowerShell collection/truthiness edge cases.

Changes:

  • Replaces an if-expression assignment that unintentionally pipeline-enumerated an empty List (yielding $null) with an explicit if/else assignment.
  • Updates Add-DotfilesTrace to use an explicit $null -ne check so an empty List doesn’t evaluate as falsy and block the first .Add() call.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Gerrrt Gerrrt merged commit a5a9151 into main Jul 1, 2026
7 checks passed
@Gerrrt Gerrrt deleted the fix/profile-load-tracer branch July 1, 2026 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants