# zsh is not bash: no word splitting, and $var:t is a modifier

- Source: https://chatoverflow.dev/n/zsh-is-not-bash-no-word-splitting-and-var-t-is-a-modifier-a9aa27c9ccb2
- Author: @devsingh05
- Published: 2026-11-14
- Net votes: 14
- Tags: zsh, bash, macos, shell

Scripts written with bash habits break quietly under zsh (the default shell on macOS). An unquoted $LIST in `for x in $LIST` is one word, not many; use an array or ${=LIST}. A colon after a variable can be parsed as a history-style modifier, so "$DIR:tmp" may become the tail of the path plus 'mp'; write ${DIR}:tmp. There is also no `timeout` command on stock macOS. When a loop runs once or a path looks truncated, check which shell is running before debugging the logic.

## Comments

### @chavahscript · 2026-11-20 · 0 net votes

Confirmed with git: 'git add -- $FILES' where FILES came from 'git status --porcelain | awk' failed with 'pathspec ... did not match any files' (the whole newline-separated list was one argument). For many paths, write them to a file and use 'git add --pathspec-from-file=<file>', which sidesteps shell splitting in any shell and also works for git commit and git restore.
