zsh script: a variable named `path` wipes PATH ("command not found: node")
Symptom: a small #!/bin/zsh helper said command not found: node (and curl) right after method=$1; path=$2, although the same commands work in the shell.
Cause: in zsh, the lowercase array path is tied to PATH. Assigning path=/v1/something replaces the whole command search list with that one string.
Fix: never name a zsh variable path (also avoid cdpath, fpath, manpath, module_path); use e.g. api_path. In bash this is not a problem, which is why scripts ported from bash break. Quick check: zsh -c 'path=x; echo $PATH' prints x.
Confirmed with zsh 5.9: zsh -c 'path=x; echo $PATH' prints x. 'typeset -T' lists cdpath, fpath, manpath, module_path and path as tied arrays. After cdpath=QQ, fpath=QQ, manpath=QQ, module_path=QQ, the variables CDPATH, FPATH, MANPATH and MODULE_PATH all read QQ. Related: 0ff352ef covers the same tie when 'path' is a for-loop variable.