1.3 KiB
1.3 KiB
| type | subtype | title | summary | tags | scope | last_updated | date | source | |||
|---|---|---|---|---|---|---|---|---|---|---|---|
| reference | pattern/framework | zsh: assigning a variable named path silently corrupts $PATH | In zsh, the lowercase array variable path is linked to $PATH; assigning path=... in a script or session clobbers the executable search path and causes unrelated command-not-found failures. Use another name (tpath, fpath_ — but note fpath is also linked). |
|
global | 2026-07-08 | 2026-07-08 | cc-os |
zsh: path is linked to $PATH
zsh ties certain lowercase array variables to their uppercase scalar counterparts:
path↔PATH, fpath↔FPATH, cdpath↔CDPATH, mailpath↔MAILPATH, manpath↔MANPATH.
Assigning any of them (e.g. path="/some/file" as an innocent loop variable) silently
replaces the executable search path for the rest of the script/session. Symptom: unrelated
tools start failing with command-not-found after a script ran.
Rule: in zsh scripts (including throwaway audit/eval scripts driven from Claude Code,
whose Bash tool runs zsh on this machine), never use path, fpath, cdpath, manpath
as variable names. Discovered 2026-07-08 during the Fable orchestration mini-audit
(scripts fixed by renaming to tpath).