[Windows] PowerShell tool guidance: prefer -LiteralPath for file paths (brackets are wildcards with -Path)
还没有人认领这个 Issue。
评估
- 难度
- 1/5
- 预计耗时
- 1 小时以内
- 新手友好度
- 74/100
- Issue 类型
- 功能
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- powershell
调研方向
找到内置的 PowerShell 工具指南,并阅读现有的 Windows 提示,了解 && 与 ; 的区别以及 heredoc。简要补充说明:在支持的情况下,对具体的源路径使用 -LiteralPath,仅在有意进行通配符匹配时使用 -Path。当指南涵盖了这一区别及所列的源路径 cmdlet,且没有暗示这也适用于目标参数时,即为完成。
由索引模型根据 Issue 内容生成。
描述
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
-LiteralPathwhere supported; quoting-Pathdoes not disable wildcard expansion ([ ] * ?). Use-Pathonly when wildcard matching is intentional. (This applies to source paths such asGet-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].jpgfail with-Path; the agent then retries with-LiteralPath. - "Delete del[2].jpg":
Remove-Item -Path 'del[2].jpg'deletesdel2.jpgif it exists, and the requested file stays. - "Edit notes [draft].md":
Set-Content -Pathfails 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
Docs: about_Wildcards and Supporting Wildcard Characters in Cmdlet Parameters / -LiteralPath.
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".
- 主要语言
- Python
- 星标
- 11.5k
- 派生
- 2k
- 平均合并
- 6 小时 34 分钟
- 30 天内合并 PR
- 3
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
github/copilot-cli 的其他 Issue
-
area:plugins
难度 2/5 1-3 小时 新手友好度 75/100
github/copilot-cli#5567 ·
-
难度 1/5 1-3 小时 新手友好度 78/100
github/copilot-cli#5489 ·
-
Built-in functions.view returns no content for large files despite documenting automatic truncation未关闭area:tools
难度 2/5 1-3 小时 新手友好度 72/100
github/copilot-cli#5476 ·
-
triage
难度 1/5 1 小时以内 新手友好度 74/100
github/copilot-cli#5377 ·
-
area:configuration area:models
难度 2/5 1-3 小时 新手友好度 67/100
github/copilot-cli#5287 ·
查看 github/copilot-cli 的全部 Issue
相似的 Issue
-
fidelity
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
backlog
难度 2/5 1-3 小时 新手友好度 72/100
sagemathinc/sagebrush#3434 ·
维护者通常 1 天内回复
-
marketing
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复
-
documentation good first issue help wanted
难度 2/5 1-3 小时 新手友好度 78/100
wuisabel-gif/MemWhale#576 ·
维护者通常 1 天内回复
-
Status: Triage Suggestion
难度 2/5 1-3 小时 新手友好度 68/100
GTNewHorizons/GT-New-Horizons-Modpack#27957 ·
维护者通常 1 天内回复