[Bug] Bash parser shows spurious directory access prompts when command analysis fails
Bug Description
When Claude Code's bash parser can't fully analyze a command, it sometimes shows an "always allow access to [directory]" prompt even though directory access isn't the issue. Selecting the "always allow" option doesn't persist - the same prompt appears again on the next command. The directory is already accessible for other commands (grep, head, etc. work fine), making this extra confusing.
Reproduction 1: Standalone command not in allow list
With Bash(sed *) NOT in the allow list:
- Run
sed -n '1p' README.md - Prompt appears with "Yes, and always allow access to project/ from this project" option
- Select the always allow option → command runs
- Run
sed -n '1p' README.md(same command) - Prompt appears without the "always allow" option (generic yes/no only)
The directory access prompt was wrong - the actual issue was sed not being in the allow list.
Reproduction 2: For loop with allowed command in body
With Bash(sed *) in the allow list:
- Run:
````
for f in README.md
do
sed -n '1p' "$f"
done
- Prompt appears with "Yes, and always allow access to project/ from this project" option
- Select the always allow option → command runs
- Run the exact same command again
- Same exact prompt appears again
This affects for loops with wc, head, awk, sed, sort, cut, file, diff in the body.
Reproduction 3: rm + glob
- Create test files:
touch ./test-1.txt ./test-2.txt - Run
rm ./test-*.txt - Prompt appears with "Yes, and always allow access to project/ from this project" option
- Select the always allow option → files deleted
- Create files again and run the same rm command
- Same exact prompt appears again
Expected behavior
If the parser can't determine what permission to offer, it should show a generic yes/no prompt without a spurious "always allow" option. For loops containing allowed commands in the body should either be allowed or fail for the correct reason.
Environment Info
- Platform: darwin
- Terminal: WezTerm
- Version: 2.1.29
- Feedback ID: d065e5eb-a5dd-4c3f-9225-172137e0847a
Errors
[{"error":"Error: String not found in file. Failed to apply edit.\n at $kT (/$bunfs/root/claude:1463:731)\n at iCR (/$bunfs/root/claude:1463:107)\n at HWB (/$bunfs/root/claude:2153:123)\n at Se_ (/$bunfs/root/claude:1682:2302)\n at i$ (/$bunfs/root/claude:672:20681)\n at wq (/$bunfs/root/claude:672:38949)\n at Mt (/$bunfs/root/claude:672:49471)\n at cj (/$bunfs/root/claude:672:85493)\n at dt (/$bunfs/root/claude:672:84475)\n at im (/$bunfs/root/claude:672:84301)","timestamp":"2026-02-02T04:58:44.182Z"},{"error":"Error: String not found in file. Failed to apply edit.\n at $kT (/$bunfs/root/claude:1463:731)\n at iCR (/$bunfs/root/claude:1463:107)\n at HWB (/$bunfs/root/claude:2153:123)\n at Se_ (/$bunfs/root/claude:1682:2302)\n at i$ (/$bunfs/root/claude:672:20681)\n at wq (/$bunfs/root/claude:672:38949)\n at Mt (/$bunfs/root/claude:672:49471)\n at cj (/$bunfs/root/claude:672:85493)\n at dt (/$bunfs/root/claude:672:84475)\n at im (/$bunfs/root/claude:672:84301)","timestamp":"2026-02-02T05:00:06.550Z"},{"error":"Error: String not found in file. Failed to apply edit.\n at $kT (/$bunfs/root/claude:1463:731)\n at iCR (/$bunfs/root/claude:1463:107)\n at HWB (/$bunfs/root/claude:2153:123)\n at Se_ (/$bunfs/root/claude:1682:2302)\n at i$ (/$bunfs/root/claude:672:20681)\n at wq (/$bunfs/root/claude:672:38949)\n at Mt (/$bunfs/root/claude:672:49471)\n at cj (/$bunfs/root/claude:672:85493)\n at dt (/$bunfs/root/claude:672:84475)\n at im (/$bunfs/root/claude:672:84301)","timestamp":"2026-02-02T05:00:08.316Z"},{"error":"Error: String not found in file. Failed to apply edit.\n at $kT (/$bunfs/root/claude:1463:731)\n at iCR (/$bunfs/root/claude:1463:107)\n at HWB (/$bunfs/root/claude:2153:123)\n at Se_ (/$bunfs/root/claude:1682:2302)\n at i$ (/$bunfs/root/claude:672:20681)\n at wq (/$bunfs/root/claude:672:38949)\n at Mt (/$bunfs/root/claude:672:49471)\n at cj (/$bunfs/root/claude:672:85493)\n at dt (/$bunfs/root/claude:672:84475)\n at im (/$bunfs/root/claude:672:84301)","timestamp":"2026-02-02T05:00:16.728Z"},{"error":"Error: String not found in file. Failed to apply edit.\n at $kT (/$bunfs/root/claude:1463:731)\n at iCR (/$bunfs/root/claude:1463:107)\n at HWB (/$bunfs/root/claude:2153:123)\n at Se_ (/$bunfs/root/claude:1682:2302)\n at i$ (/$bunfs/root/claude:672:20681)\n…
Note: Content was truncated.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗