[BUG] Windows 10 Terminal - Echo text incorrectly parsed as executable commands when chaining with PowerShell
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?
When running a bash command that combines echo with PowerShell via &&, the bash interpreter incorrectly parses the echo string content as executable commands, causing a cascade of "command not found" errors.
Specifically, when executing:
echo "Checking if files can be recovered from Recycle Bin..." && powershell -Command "Get-ChildItem ..."
The text "Checking if files can be recovered from Recycle Bin..." gets interpreted as bash commands instead of being treated as a string literal, resulting in hundreds of repeated errors:
Checking : The term 'Checking' is not recognized as the name of a cmdlet, function, script file, or operable program.
This also occurred with subsequent commands using Where-Object { ... } where the content inside the script block was similarly misinterpreted.
What Should Happen?
The echo command should print the string to stdout, then PowerShell should execute independently. The echo string should never be parsed as executable code. The command should either:
- Successfully print the message and run PowerShell, OR
- Fail cleanly with a single error message if there's a syntax issue
Text within PowerShell script blocks ({ }) should be passed to PowerShell unchanged and not interpreted by the bash shell.
Error Messages/Logs
Checking : The term 'Checking' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:94
+ ... Force -ErrorAction SilentlyContinue | Where-Object { Checking if file ...
+ ~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Checking:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
This error repeated hundreds of times with various text fragments being misinterpreted as commands.
Steps to Reproduce
-
In Claude Code, use the Bash tool with a command combining echo and PowerShell:
echo "Checking if files can be recovered from Recycle Bin..." && powershell -Command "Get-ChildItem -Path 'C:\$Recycle.Bin' -Recurse -Force -ErrorAction SilentlyContinue | Where-Object { $_.Name -like '*Jorja*' -or $_.Name -like '*Tyler*' } | Select-Object FullName, Name" -
Observe that instead of echoing the text and running PowerShell, the bash interpreter attempts to execute words from the echo string as commands
-
The error cascades because the PowerShell script block content is also being misinterpreted
Alternative reproduction: echo "Some text here" && powershell -Command "Get-ChildItem | Where-Object { Some text here }"
Claude Model
Sonnet (default)
Is this a regression?
I don't know
Last Working Version
No response
Claude Code Version
2.0.14 (Claude Code)
Platform
Other
Operating System
Windows
Terminal/Shell
Windows Terminal
Additional Information
- This appears to be a shell escaping/quoting issue specific to Windows bash environments
- The problem manifests when combining multiple commands with && where one command contains natural language text
- PowerShell script blocks with { } seem particularly problematic
- The issue caused the Bash tool to output truncated results (30175 characters truncated message appeared)
- Workaround: Avoid using echo with descriptive text before PowerShell commands; run PowerShell directly or use separate Bash tool calls
This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.