[BUG] Bogus "ANSI-C quoting" in Bash permission prompt rationale
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
This command line does not actually contain any ANSI-C quoting:
Bash command
ls /Users/(me)/git/(project)/logs/ | grep '^log-' | grep '\.json$' | tail -5; ls
/Users/(me)/git/(project)/logs/ | grep '^log-' | grep '\.json$' | wc -l
Count and sample log JSON files
Command contains ANSI-C quoting which can hide characters
Do you want to proceed?
❯ 1. Yes
2. No
Esc to cancel · Tab to amend
What Should Happen?
Ideally, Claude should not display a prompt for this command if it doesn't actually contain ANSI-C quoting. (Also, Claude should know how to do ls ./log-*.json instead of the stupid multiple grep filters!) Less ideally, do not display a rationale for the prompt which isn't true.
Error Messages/Logs
Steps to Reproduce
I am not sure whether this is reproducible. I managed to get the same prompt again by asking Claude to rerun this same command but I'm unclear on what exactly the criteria for that prompt are. My suspicion is that it looks for $' and doesn't realize that this doesn't apply when that's the _end_ of a single-quoted string. I do not get the prompt forecho 'foo$' or cat /etc/manpaths | grep '\.json$' | tail
Claude Model
Sonnet (default)
Is this a regression?
No, this never worked
Last Working Version
_No response_
Claude Code Version
2.1.50 (Claude Code)
Platform
AWS Bedrock
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
This is quite similar to my earlier bug report https://github.com/anthropics/claude-code/issues/27899 but I'm filing it as a separate issue just in case.
Showing cached comments. Read the full discussion on GitHub ↗
13 Comments
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
None of these are even remotely related except the last one, which I already mentioned. It's a different part of the Bash syntax and a different warning message so I am keeping these separate.
I'm running into this(ish) issue too. By way of suggestion, CC could use a library/tool like
shfmt<https://github.com/mvdan/sh> to get a parse tree from the text and thereby be able to only flag commands that _actually_ contain ANSI-C strings with\xescapes (and not non-strings, or ANSI-C strings that don't have arguably-sneaky escapes).Adding a noise comment to avoid hav ing this closed.
Adding another noise comment to prevent this from being closed.
Adding a noise comment to prevent this from being closed.
Adding a noise comment to prevent this from being closed.
Adding a noise comment to prevent this from being closed.
Adding a noise comment to prevent this from being closed.
Adding a noise comment to prevent this from being closed.
Adding a noise comment to prevent this from being closed.
Adding a noise comment to prevent this from being closed.
Adding a noise comment to prevent this from being closed.