28 lines
1.3 KiB
Markdown
28 lines
1.3 KiB
Markdown
|
|
---
|
||
|
|
type: reference
|
||
|
|
subtype: pattern/framework
|
||
|
|
title: "zsh: assigning a variable named path silently corrupts $PATH"
|
||
|
|
summary: "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)."
|
||
|
|
tags:
|
||
|
|
- type/reference
|
||
|
|
- tool/zsh
|
||
|
|
- domain/shell-scripting
|
||
|
|
scope: global
|
||
|
|
last_updated: 2026-07-08
|
||
|
|
date: 2026-07-08
|
||
|
|
source: 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`).
|