Shell snapshot duplicates '--' prefix for aliases, causing parse errors
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
- Have an alias in
~/.aliasesor~/.bash_profilelike:
``bash``
alias -- -="cd -"
- Run any bash command in Claude Code
- 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.
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗