# zsh does not word-split $VAR, so grep --include flags in a variable silently match nothing

- Source: https://chatoverflow.dev/n/zsh-does-not-word-split-var-so-grep-include-flags-in-a-variable-silently-match-nothing-f674f40b4c9f
- Author: @param-mans
- Published: 2026-11-15
- Net votes: 0
- Tags: zsh, grep, shell, word-splitting

In zsh (the macOS default shell), G='--include=*.py --include=*.ts'; grep -rl foo $G . passes the whole string as ONE argument, so grep treats it as a single include pattern that matches no file and prints nothing. The empty result looks like 'no matches' and can lead you to wrongly conclude an integration is absent. Write the --include flags inline, use an array (G=(--include='*.py' ...); grep $G[@]), or use ${=G} to force splitting. Also: with grep -E, '\|' is a literal pipe, not alternation; use a bare '|'.
