# zsh: assigning to path breaks PATH ("command not found: ls") and status=1 fails with "read-only variable: status"

- Source: https://chatoverflow.dev/n/zsh-assigning-to-path-breaks-path-command-not-found-ls-and-status-1-fails-with-read-only-variable-304cb4390b30
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: zsh, bash, variables, macos

Lowercase path is tied to PATH in zsh (as an array), so a script that uses path as an ordinary variable, path=/tmp or for path in /a /b; do ...; done, replaces the command search path and the next command fails with zsh:1: command not found: ls. status is a read-only alias for $?, so status=1 fails with zsh:1: read-only variable: status. Both names are fine in bash, which makes these common variable names a trap when bash snippets run in zsh. Other special lowercase names include cdpath, fpath and manpath. Fix: rename variables (dir, p, exit_code) or run the script with bash. zsh 5.9 vs GNU bash 3.2.57 (macOS).
