[Windows] PowerShell tool guidance: prefer -LiteralPath for file paths (brackets are wildcards with -Path)
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 1/5
- Tempo estimado
- Menos de uma hora
- Facilidade para iniciantes
- 74/100
- Tipo de issue
- Funcionalidade
- Clareza
- Claramente especificada
- Status de atividade
- Ativa
- Stack de tecnologia
- powershell
- Domínio
- developer-experience
Direção de pesquisa
Encontre as orientações da ferramenta PowerShell integrada e leia as dicas existentes para Windows sobre && em comparação com ; e sobre heredocs. Acrescente orientações concisas para usar -LiteralPath em caminhos de origem concretos quando houver suporte e reservar -Path para correspondências intencionais com curingas. O trabalho estará concluído quando as orientações abordarem a distinção e os cmdlets listados para caminhos de origem, sem dar a entender que isso se aplica a parâmetros de destino.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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".
- Linguagem predominante
- Python
- Estrelas
- 11.5k
- Forks
- 2k
- Merge médio
- 6h 34min
- PRs com merge (30d)
- 3
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Sem modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de github/copilot-cli
-
area:plugins
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
github/copilot-cli#5567 ·
-
Dificuldade 1/5 1-3 horas Facilidade para iniciantes 78/100
github/copilot-cli#5489 ·
-
Built-in functions.view returns no content for large files despite documenting automatic truncationAbertaarea:tools
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
github/copilot-cli#5476 ·
-
triage
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 74/100
github/copilot-cli#5377 ·
-
area:configuration area:models
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 67/100
github/copilot-cli#5287 ·
Todas as issues de github/copilot-cli
Issues semelhantes
-
fidelity
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
Mantenedores costumam responder em até 1 dia
-
backlog
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
sagemathinc/sagebrush#3434 ·
Mantenedores costumam responder em até 1 dia
-
marketing
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
Mantenedores costumam responder em até 1 dia
-
documentation good first issue help wanted
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
wuisabel-gif/MemWhale#576 ·
Mantenedores costumam responder em até 1 dia
-
Status: Triage Suggestion
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
GTNewHorizons/GT-New-Horizons-Modpack#27957 ·
Mantenedores costumam responder em até 1 dia