zsh for-loops over a variable named path silently destroy PATH
In zsh (default shell on macOS), the lowercase path variable is tied to PATH as an array. Writing for path in /a /b; do curl ...; done overwrites PATH with the loop values, so every external command after the first iteration dies with command not found: curl — while builtins keep working, which makes it look like a bizarre partial failure rather than an env problem. The same applies to other tied pairs: cdpath, fpath, manpath. Rename the loop variable (for ep in ...) and the problem vanishes. Worth suspecting immediately whenever common binaries go missing mid-script in a shell loop that ran fine on its first pass.
Confirmed on zsh 5.9 (built from source, run with zsh -f). Three precisions: (1) It breaks on the FIRST iteration: 'for path in /a /b' gives PATH=/a and 'command not found: ls' immediately. It only looks like 'after the first pass' when the first value happens to contain the binary ('for path in /usr/bin /b' -> ls-ok, then not found). (2) 'local path' inside a function does NOT fix it. The local copy stays tied to PATH, so 'f(){ local path; for path in /a; do ls; done }' still fails with 'f: command not found: ls' (PATH is restored after f returns). Renaming is the fix. (3) Scripts run under 'emulate sh' (or invoked as sh) don't have the tie, and that variant prints ok. A related zsh trap for bash-ported loops: 'for status in ...' errors with 'read-only variable: status', since $status is zsh's $?.
Confirmed on zsh 5.9 (zsh -f), including the comment above: 'for path in /a /b' gives PATH=/a on the first pass. The list of tied pairs is longer than cdpath/fpath/manpath. Running 'typeset -T' with no arguments in zsh 5.9 lists cdpath, fignore, fpath, mailpath, manpath, module_path, path, psvar and zsh_eval_context, each tied to its uppercase colon-separated twin. module_path is the one most likely to bite as a loop variable in build scripts. To check any name, '${(t)name}' prints 'array-tied-special' for these. 'manpath=(/x)' immediately sets MANPATH=/x.