Skip to content

[BUG] Shell Snapshot Generates Invalid Commands #16231

@Henry-Bonikowsky

Description

@Henry-Bonikowsky

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

Root Cause

The shell snapshot generation is incorrectly parsing bash options from set -o output, creating standalone invalid commands instead of proper set -o statements.

Snapshot Content (lines 3-5):

or                    # INVALID - should be "set -o monitor"
set -o onecmd         # CORRECT
heckhash              # INVALID - should be "set -o hashall"

Shell snapshots contain invalid standalone commands or and heckhash that cause "command not found" errors.

What Should Happen?

Shell snapshots should generate valid bash commands that can be sourced without errors.

Actual Snapshot Content (lines 3-5):

or                    # INVALID - should be "set -o monitor"
set -o onecmd         # CORRECT
heckhash              # INVALID - should be "set -o hashall"

Error Messages/Logs

Every bash command execution produces these errors:

>     /c/Users/henry/.claude/shell-snapshots/snapshot-bash-*.sh: line 3: or: command not found
>     /c/Users/henry/.claude/shell-snapshots/snapshot-bash-*.sh: line 5: heckhash: command not found

Steps to Reproduce

Steps to Reproduce

  1. Use Claude Code on Windows with Powershell/Git Bash Mingw64
  2. Have monitor and/or hashall bash options enabled
  3. Execute any bash command via Claude Code
  4. Observe the errors in output

Claude Model

Not sure / Multiple models

Is this a regression?

No, this never worked

Last Working Version

No response

Claude Code Version

2.0.76

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

Powershell/Git Bash(MINGW64)

Additional Information

Additional Context

The bug appears to be in the snapshot generation logic that processes the output of set -o. It's likely:

  • Missing the set -o prefix for certain options
  • Incorrectly truncating option names (e.g., "monitor" → "or", "hashall" → "heckhash")

Attempted Workarounds (All Failed)

  1. Modifying user .bashrc to disable options - file modification fails
  2. Deleting snapshot files - regenerated with same bug
  3. Using bash --noprofile --norc - snapshots still sourced
  4. Editing snapshot files directly - overwritten immediately

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:toolsbugSomething isn't workinghas reproHas detailed reproduction stepsplatform:windowsIssue specifically occurs on Windows

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions