Why Claude Code's shell commands often fail on macOS and how to fix it
Developers using Claude Code on macOS frequently encounter failing shell commands due to two underlying technical issues unrelated to AI model quality. First, Claude Code's Bash tool actually runs commands through zsh on macOS Catalina and later, despite being labeled as a Bash executor, causing subtle behavioral differences in glob handling and syntax. Second, macOS ships with BSD versions of standard tools like sed, date, and stat, while Claude generates commands assuming GNU versions, leading to silent errors or unexpected file creation. A common example is the sed -i command, which silently creates a backup file on macOS instead of editing in place, and exits with a success code that masks the problem. Fixing PATH to prioritize GNU tools via brew has no effect because Claude Code captures its shell environment at session start from its own process, not from the user's configured shell profile.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in