Skip to content

Stop profile aliases from shadowing built-in commands - #8

Merged
26zl merged 2 commits into
mainfrom
fix/no-builtin-alias-shadowing
Oct 11, 2026
Merged

26zl merged 2 commits into
mainfrom
fix/no-builtin-alias-shadowing

Conversation

@26zl

@26zl 26zl commented Oct 11, 2026

Copy link
Copy Markdown
Owner

Why (draft: PowerShell runtime behavior not fully verifiable here)

The profile called Remove-Alias on the built-in gc, ls, and cat aliases and then redefined them. Because the alias table is shared across the whole session, this replaced Get-Content / Get-ChildItem for every script run afterward (e.g. a script at the prompt doing gc config.json or cat x), not just the interactive prompt.

Changes

  • gc -> gcmsg: rename the git-commit helper and remove Remove-Alias gc, so the built-in gc (Get-Content) stays intact.
  • ls: drop the Remove-Alias ls + function ls; keep eza under la / ll / lt (which do not collide with a built-in alias). ls stays Get-ChildItem.
  • cat: drop the Remove-Alias cat + function cat; expose bat as bcat. cat stays Get-Content.
  • ssh wrapper: now resolves the host's effective config with ssh -G <host> and adds ConnectTimeout / ServerAliveInterval / ServerAliveCountMax only where neither the command line nor ~/.ssh/config already set them (ssh -G reports unset ConnectTimeout as none, unset ServerAliveInterval as 0). Previously it keyed only off the command line and would override values from ~/.ssh/config.
  • Correct the inaccurate gpush / gpull comments (they claimed to remove gp/gl aliases and misnamed the built-ins).
  • Update Show-Help text, the command registry, README alias tables, and the gc test call sites (tests/test.ps1, tests/ci-functional.ps1) to match.

Findings / rationale

  • Any session-scoped override of these names affects later scripts regardless of alias-vs-function precedence, so the only safe fix is to not bind the modern tools to the built-in names. Chose distinct names (per the review's first option) over an opt-in flag to keep the change minimal and safe-by-default.
  • In CI (Windows, no eza/bat) the ls/cat probes already exercised the built-ins, so they stay valid; gcmsg is defined unconditionally.

Verification

  • Parser::ParseFile clean on profile, tests/test.ps1, tests/ci-functional.ps1.
  • PSScriptAnalyzer (CI exclude set) on the profile: 0 findings.
  • Unverified here: runtime behavior of the ssh wrapper (needs a Windows ssh.exe + an interactive session for the tab-title path); bcat only exists when bat is installed. No workflows touched.

26zl added 2 commits October 11, 2026 14:44
The profile removed the built-in gc/ls/cat aliases with Remove-Alias and
redefined them, which replaced Get-Content/Get-ChildItem for the whole
session, including scripts invoked from the prompt.

- Rename the git-commit helper gc -> gcmsg and drop Remove-Alias gc.
- Expose eza via la/ll/lt only; leave the built-in ls alias intact.
- Expose bat via bcat; leave the built-in cat alias intact.
- ssh: consult `ssh -G <host>` and add ConnectTimeout/ServerAlive* only
  where neither the command line nor ~/.ssh/config already set them.
- Correct the misleading gpush/gpull alias comments.
- Update help text, command registry, README, and tests to match.
bcat is a new command exposed only when bat is installed. The coverage
audit parses the profile statically, so it sees the bcat function
regardless of the runtime bat guard and flagged it as an uncovered
export, failing the functional job. Probe bcat when bat is present and
skip it with a reason otherwise.
@26zl
26zl marked this pull request as ready for review October 11, 2026 14:37
@26zl
26zl merged commit 4e0ad96 into main Oct 11, 2026
5 of 6 checks passed
@26zl
26zl deleted the fix/no-builtin-alias-shadowing branch October 11, 2026 14:37
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.

1 participant