Directory reset not triggered when `cd` is inside a sourced script
Resolved 💬 3 comments Opened Jan 2, 2026 by ykdojo Closed Feb 17, 2026
Steps to Reproduce
1. Direct cd outside project (reset works):
$ cd /tmp
Shell cwd was reset to /Users/yk/Desktop/projects/claude-code-tips
$ pwd
/Users/yk/Desktop/projects/claude-code-tips
2. cd via sourced script (reset not triggered):
$ echo 'cd /tmp' > /tmp/escape.sh
$ source /tmp/escape.sh
$ pwd
/private/tmp
Expected Behavior
After sourcing a script containing cd /tmp, the shell should reset back to the project directory.
Actual Behavior
The working directory permanently changes to /private/tmp.
Note
This was reviewed by Anthropic security (HackerOne #3480366) and closed as Informative - not considered a security vulnerability since users approve each command. Filing as a behavioral inconsistency.
Environment
- Claude Code 2.0.76
- macOS 15.6.1
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗