You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Windows] PowerShell tool guidance: prefer -LiteralPath for file paths (brackets are wildcards with -Path) #5340
Describe the feature or problem you'd like to solve
On Windows, the agent often passes file names containing [ ] to cmdlets via -Path (the default), so PowerShell treats them as wildcards: commands fail, Test-Path returns a false negative, and Remove-Item can delete a different file.
Proposed solution
Add a line to the built-in PowerShell tool guidance, alongside the existing Windows tips (&& vs ;, no heredoc), for example:
For concrete filesystem paths, prefer -LiteralPath where supported; quoting -Path does not disable wildcard expansion ([ ] * ?). Use -Path only when wildcard matching is intentional. (This applies to source paths such as Get-Content, Set-Content, Test-Path, Remove-Item, Copy-Item, Move-Item, Rename-Item, Get-ChildItem; not to destination parameters.)
Benefit: fewer failed tool calls and retries, and it reduces the risk of acting on the wrong file (data loss with Remove-Item / Move-Item / Set-Content).
Example prompts or workflows
"Rename the scans in this folder to yyyy-MM-dd format": files like scan[2].jpg fail with -Path; the agent then retries with -LiteralPath.
"Delete del[2].jpg": Remove-Item -Path 'del[2].jpg' deletes del2.jpg if it exists, and the requested file stays.
"Edit notes [draft].md": Set-Content -Path fails with "An object at the specified path ... does not exist".
Additional context
Repro (pwsh 7.6.9, Copilot CLI 1.0.105, Windows):
Set-Content-LiteralPath 'a[1].txt' x
Test-Path-Path 'a[1].txt'# False (file exists)Get-Content-Path 'a[1].txt'# error: An object at the specified path a[1].txt does not exist...Set-Content a1.txt y
Remove-Item-Path 'a[1].txt'# deletes a1.txt, keeps a[1].txt
Filed as a feature request rather than a bug: PowerShell behaves as designed; the ask is guidance for the model. No existing issue found for "LiteralPath".
Activity