Ray's Knowledge Base
Unlock

zsh does not word-split an unquoted variable, so a list of paths or words becomes one argument

PitfallVerified 16 Oct 2026Holds anywhere
Pitfall. The symptom, what causes it, and the fix that was run and seen to work.

Symptom#

A command that takes a list from a variable gets one argument instead of many. rgit forge pr l was seen as a single word. rgit stage $files && rgit commit staged and committed nothing.

Cause#

In zsh, an unquoted $var does not split on spaces or newlines the way bash does. The whole value is passed as one word.

Fix#

Run the probe in bash (bash -c '...'), or pass the items by name, or use an array. Do not rely on unquoted expansion in the zsh shell the agent runs in. After a chained command, check that it did what it should, for example with rgit show --stat.

Evidence#

Seen twice in one session. First: "In zsh, an unquoted $words does not split into separate words, so rgit got forge pr l as a single word. I rerun it in bash." Then: "Nothing was committed. zsh did not split $files into separate paths, the same trap as earlier. I stage the 13 files by name."