[BUG] Bash tool fails with command substitution in pipe arguments
Resolved 💬 3 comments Opened Dec 18, 2025 by trickv Closed Jan 20, 2026
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?
Command substitution $(date ...) fails when used as an argument to a piped command like tee.
Reproduction: get Claude to run:
echo "test" | tee test-$(date +%Y%m%d_%H%M%S).log
Error:
(eval):1: unknown file attribute:
Expected: Should create a log file with timestamp
Simple pipes without command substitution do work fine...
echo "test" | tee foo.log
What Should Happen?
Fails with "unknown file attribute" error
Error Messages/Logs
● You're right - I should have noticed that both attempts with tee failed. I'll 01:49 PM claude-sonnet-4-5-20250929
remember not to use piping to tee in future commands.
Instead, I should either:
1. Run the command directly and let output go to terminal
2. Redirect to a file with > logfile.log 2>&1
3. Use the run_in_background parameter if needed and monitor output separately
Thanks for the feedback - I won't use pipe to tee going forward.
> I wonder if this is a bug in claude code; can you try to reproduce it? can you run "echo hello 2>&1 | tee foo.log" and
see if it works?
● Bash(echo hello 2>&1 | tee foo.log)
⎿ hello
● Bash(cat foo.log)
⎿ hello
● That worked fine. Let me try with the date substitution like we did before: 01:50 PM claude-sonnet-4-5-20250929
● Bash(echo "test log" 2>&1 | tee test-$(date +%Y%m%d_%H%M%S).log)
⎿ Error: Exit code 1
(eval):1: unknown file attribute:
● There's the issue! The $(date +%Y%m%d_%H%M%S) command substitution fails with 01:52 PM claude-sonnet-4-5-20250929
"unknown file attribute". This appears to be a Claude Code issue with how it
handles command substitution in pipes. The workaround we tried (setting LOGFILE
variable first) also failed.
So yes, this looks like a bug in Claude Code's Bash tool - it can't properly
handle $(...) command substitution when used with pipes. Simple pipes work, but
command substitution in the piped arguments breaks.
Good catch! For now, the workaround is to either:
1. Use > redirection instead of tee
2. Pre-create the filename without command substitution
3. Use a hardcoded filename
Steps to Reproduce
Ask Claude Code to run: echo "test log" 2>&1 | tee test-$(date +%Y%m%d_%H%M%S).log
Claude Model
Sonnet (default)
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.0.64
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
Other
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗