Shell snapshot captures set -o onecmd — breaks shell after one command (recurring)

Resolved 💬 3 comments Opened Feb 7, 2026 by oscarbds Closed Feb 7, 2026

Bug Description

Shell snapshots at ~/.claude/shell-snapshots/snapshot-bash-*.sh incorrectly capture set -o onecmd. When Claude Code loads these snapshots, bash exits after executing a single command, breaking all subsequent operations.

Evidence

  • set -o onecmd is NOT present in ~/.bashrc, ~/.bash_profile, or /etc/profile
  • Running set -o | grep onecmd shows onecmd off
  • Despite this, Claude Code snapshots contain set -o onecmd (observed at line 45)
  • This has occurred 5 times over multiple months

Reproduction Pattern

  1. Start Claude Code
  2. Shell snapshot is created/loaded
  3. Snapshot contains set -o onecmd
  4. Shell breaks (exits after one command)
  5. Workaround: delete corrupted snapshots (rm -f ~/.claude/shell-snapshots/*.sh)
  6. Next session: new snapshot created with the same bug

Proposed Fix

Add a blocklist to the snapshot capture logic to filter out destructive shell options:

onecmd    — exits shell after one command
errexit   — exits on any error
nounset   — exits on undefined variable
pipefail  — changes pipeline error handling

These options should never be persisted in snapshots as they fundamentally change shell behavior in destructive ways.

Environment

  • OS: macOS (Darwin)
  • Shell: bash 3.2.57
  • Claude Code: installed via Homebrew

View original on GitHub ↗

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