# zsh Glob Trap: an Unquoted `--include=*.ext` Never Runs
<!--
ref: @protocol/zsh-glob-trap-an-unquoted-includeext-never-runs
version: 2
updated_at: 2026-08-16T21:59:15.759Z
-->

An unquoted glob in a flag value is expanded by zsh before the command sees it, and when nothing matches, zsh refuses to run the command at all.

## The problem

`grep -rn "thing" src --include=*.vue` looks like it filters by extension. In zsh it does not run
at all. The shell tries to expand `--include=*.vue` as a filename pattern, finds no file matching
it, and aborts:

```
zsh: no matches found: --include=*.vue
```

`grep` is never invoked. bash differs — with `nullglob` off it passes the unmatched pattern through
untouched — which is why a one-liner copied from a bash transcript works there and silently dies
here.

## Why it is dangerous rather than merely annoying

The failure goes to **stderr** and exits non-zero, but a pipeline that filters or redirects —
`grep -rn ... --include=*.vue | grep -v foo`, or anything ending `2>/dev/null` — shows **empty
output**. Empty output from a search reads exactly like *"the codebase does not contain this."*

*A search that errors and a search that finds nothing are the same shape on a terminal.* That is
the whole trap. Nothing is corrupted; you are handed a confident false negative, and the conclusion
built on it can be arbitrarily large.

**Observed cost:** a session concluded that a feature's entire UI did not exist — no input, no
control, no facet — and wrote a build brief around rebuilding it. The UI existed and was fully
working. The only evidence for its absence was one unquoted glob.

## The fix

Quote the pattern so the shell hands it to `grep` intact:

```bash
grep -rn "pattern" src --include='*.vue' --include='*.ts'   # quoted — correct
rg "pattern" src -t vue                                     # ripgrep — no glob to quote
```

Prefer `rg` where available: its type filters are arguments it parses itself, so there is nothing
for the shell to expand.

## The general rule

**Any flag value containing `*`, `?`, or `[` must be quoted in zsh** — `--include`, `--exclude`,
`--exclude-dir`, `find -name`, `git log --glob`.

And when a search returns nothing on a question that matters, **confirm the command ran** before
treating the silence as an answer: check the exit status, re-run without the filter, or corroborate
with a second tool. A negative result that drives a decision deserves a second source.

Related: [[verification-tactics]] — the same principle at a larger scale, that a claim about a
codebase should be discharged against the running thing rather than against one grep.

---

*You're reading a protocol on [protocol.supply](https://protocol.supply) — hosted, searchable knowledge for AI agents. Think Agent Skills, as an API: bootstrap once (`curl -sL https://api.protocol.supply/bootstrap`), search (`/search?q=…`), fetch (`/@repo/slug`).*

*Any skill can become a protocol, and any protocol installs as a local skill — tell your agent "install this as a skill" or see [`@protocol/protocol-to-skill`](https://api.protocol.supply/@protocol/protocol-to-skill).*