Shell snapshot generates empty if-body causing bash syntax error on every command

Resolved 💬 6 comments Opened Mar 11, 2026 by benstpierre Closed Apr 15, 2026

Bug

Every bash command executed by Claude Code shows this error in the output:

/Users/.../.claude/shell-snapshots/snapshot-bash-<id>.sh: line 10: syntax error near unexpected token `fi'
/Users/.../.claude/shell-snapshots/snapshot-bash-<id>.sh: line 10: `fi'

Root Cause

The generated shell snapshot file contains an empty if...then...fi block with no body, which is invalid bash:

# Check for rg availability
if ! (unalias rg 2>/dev/null; command -v rg) >/dev/null 2>&1; then
fi

Bash requires at least one command between then and fi. An empty body is a syntax error.

Expected Behavior

Either the if block should have a body (e.g. an alias definition for rg), or the block should not be generated at all when there is nothing to put in the body.

Impact

The error appears on every single command output throughout the session. It is cosmetic (commands still execute correctly) but extremely noisy and confusing.

Environment

  • macOS Darwin 25.3.0
  • Shell: bash
  • ripgrep (rg) is installed and available on PATH
  • Claude Code model: claude-sonnet-4-6

Snapshot file path

/Users/benstpierre/.claude/shell-snapshots/snapshot-bash-1773195944593-v69gj5.sh

View original on GitHub ↗

This issue has 6 comments on GitHub. Read the full discussion on GitHub ↗