Why Claude Code's shell commands fail on Macs: zsh and BSD tools explained
Claude Code's Bash tool runs commands through zsh on macOS Catalina and later, despite being named and described as a Bash executor, causing subtle compatibility failures. Commands written by Claude often assume GNU tool behavior, but macOS ships with BSD versions of utilities like sed, date, and stat that interpret flags differently. A common example is 'sed -i -e', which silently creates unwanted backup files on macOS instead of editing in place, and may even exit with code 0, hiding the error from automated checks. Installing GNU tools via Homebrew does not fix the issue because Claude Code injects its own process environment — not the user's shell profile — before each command. The author identifies these as two concrete, systemic causes rather than model sloppiness, and notes that PATH modifications in shell profiles have no effect on the Bash tool's execution environment.
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