Skip to content

fix: PowerShell env var cleanup on Ctrl+C/crash#8

Open
hobostay wants to merge 1 commit into
aattaran:mainfrom
hobostay:fix/powershell-env-cleanup
Open

fix: PowerShell env var cleanup on Ctrl+C/crash#8
hobostay wants to merge 1 commit into
aattaran:mainfrom
hobostay:fix/powershell-env-cleanup

Conversation

@hobostay
Copy link
Copy Markdown

@hobostay hobostay commented May 4, 2026

Summary

  • Wraps the regular launch path in try/finally to ensure env var cleanup always runs

Problem

The remote mode already used try/finally for env cleanup, but the regular launch mode did not. If the user presses Ctrl+C or claude crashes, the cleanup code after & claude @Args is skipped. This leaks sensitive env vars into the parent shell session, including ANTHROPIC_AUTH_TOKEN which contains the API key.

Test plan

  • Launch with deepclaude.ps1 -b ds, then Ctrl+C → env vars should be cleaned up
  • Normal exit still works and cleans up

🤖 Generated with Claude Code

The regular launch mode set env vars and cleaned them up after `claude`
exits, but if the user presses Ctrl+C or the process crashes, cleanup
is skipped and the env vars (including the API key in ANTHROPIC_AUTH_TOKEN)
leak into the parent shell session. Wrap in try/finally to match the
pattern already used by the remote mode.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant