Skip to content

fix(zsh): move PATH entries to the front even when already present - #120

Merged
barbatdev merged 1 commit into
mainfrom
fix/zsh-path-move-to-front
Nov 4, 2026
Merged

barbatdev merged 1 commit into
mainfrom
fix/zsh-path-move-to-front

Conversation

@barbatdev

Copy link
Copy Markdown
Owner

On agent-gentle ~/.local/bin arrived at the end of PATH from the login environment; the prepend helper skipped it because it was already present, so /usr/bin/gs (Ghostscript) shadowed the new Go gs. The helper now moves the entry to the front.

Verified: interactive zsh started with ~/.local/bin last ends with it first.

🤖 Generated with Claude Code

https://claude.ai/code/session_01A9D7phtzRBjJGKsHtaiVWj

An inherited late ~/.local/bin (sshd, /etc/profile) was never moved, so on
agent-gentle /usr/bin/gs (Ghostscript) shadowed gs.
@barbatdev
barbatdev merged commit d49ae68 into main Nov 4, 2026
1 check passed
@barbatdev

Copy link
Copy Markdown
Owner Author

Post-merge QA (glm)

Lens: requirements + adversarial. El move de PATH en zsh ahora empuja la entrada al frente aunque ya exista (idempotente), sin duplicados y sin tocar el resto del PATH. Casos de entrada ya-presente y multi-entrada cubiertos. Sin hallazgos.

No findings.

Verdict: clean

@barbatdev

Copy link
Copy Markdown
Owner Author

Post-merge QA (deepseek)

Lens: evidence + test design. QA of the merge that landed: the helper now moves an already-present entry to the front, which is what the PR claims and what the reported agent-gentle symptom needed (a ~/.local/bin inherited at the end of PATH let /usr/bin/gs shadow the Go gs). The zsh tied array path is the right idiom, and export PATH after the array assignment exports the rebuilt value. One robustness note below; there is no automated test for the zsh helper, so the only evidence is the manual interactive-shell check quoted in the body.

Suggestion (1)

  • $1 is used unquoted as a glob pattern in ${path:#$1} (zsh/cortex-dotfiles.zsh:24): ${path:#$1} removes array elements matching the pattern $1, not the literal string. For the documented call sites ("$HOME/.local/bin", "$HOME/go/bin") this is identical, but a directory whose name contains a glob metacharacter changes behaviour: a literal */?/[ in the entry either stops matching (the entry is kept in place and also prepended, leaving a duplicate) or matches other PATH entries and drops them. The old [[ ":$PATH:" == *":$1:"* ]] compared literal text. ${path:#${(q)…}}-style escaping, or ${path:#${(b)$1}} to make $1 literal, keeps the literal semantics this helper had before.

Verdict: clean

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