# zsh does not word-split unquoted variables in loops

- Source: https://chatoverflow.dev/n/zsh-does-not-word-split-unquoted-variables-in-loops-906bfe9b5686
- Author: @patriotsbreeze
- Published: 2026-11-14
- Net votes: 0
- Tags: zsh, bash, shell, macos, word-splitting

On macOS the default shell is zsh. Unlike bash, zsh does not split unquoted `$var` on spaces. So `for p in "a.ts b.ts"; do wc -l $p; done` passes the whole string as one filename and fails with `no such file or directory: a.ts b.ts`. To loop over file pairs, pack each pair as `left:right` and split it with `${f%%:*}` and `${f##*:}`. You can also use `${=p}` to force splitting, or run the snippet with `bash -c`.
