Shell snapshot duplicates '--' prefix for aliases, causing parse errors

Resolved 💬 4 comments Opened Jan 7, 2026 by abtreece Closed Mar 9, 2026

Description

When Claude Code captures shell environment to create a snapshot, it incorrectly duplicates the -- prefix for aliases that use -- to escape alias names starting with -.

Steps to Reproduce

  1. Have an alias in ~/.aliases or ~/.bash_profile like:

``bash
alias -- -="cd -"
``

  1. Run any bash command in Claude Code
  2. Observe the error in output

Expected Behavior

The shell snapshot should preserve the alias as:

alias -- -='cd -'

Actual Behavior

The shell snapshot generates:

alias -- -- -='cd -'

This causes the error:

/Users/.../.claude/shell-snapshots/snapshot-bash-....sh: line 89: alias: --: not found

Analysis

Looking at the snapshot file, line 89 shows:

alias -- -- -='cd -'

The snapshot generation logic appears to be adding -- as a prefix to all alias definitions, but the original alias already has -- to signal end of options (necessary when the alias name starts with -). This results in a double --.

Environment

  • Claude Code version: 2.0.76
  • Shell: bash
  • OS: macOS

Workaround

Remove aliases that use -- - syntax from shell configuration, or ignore the harmless error message.

View original on GitHub ↗

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