PowerShell dynamic completion script is not valid PowerShell #5847
Labels
A-completion
Area: completion generator
C-bug
Category: bug
E-help-wanted
Call for participation: Help is requested to fix this issue.
E-medium
Call for participation: Experience needed to fix: Medium / intermediate
Please complete the following tasks
Rust Version
rustc 1.83.0 (90b35a623 2024-11-26)
Clap Version
master
Minimal reproducible code
Steps to reproduce the bug with the above code
Follow the given instructions to install PowerShell dynamic completion:
Actual Behaviour
Using the PowerShell dynamic completion installation instructions results in the PowerShell error when the profile loads:
Expected Behaviour
The argument completer should be added to the PowerShell environment successfully.
Additional Context
The PowerShell dynamic completion profile script is not valid PowerShell:
These are the main problems:
COMPLETE=powershell mycommand
does not work in PowerShell, there is no way to set environment variables inline like this. Unfortunately, the best solution is probably to assign the env var, run the command, then restore the previous value.&{completer}
may have double-quotes from theshlex::try_quote(completer)
above, which results in a syntax error like this:Invoke-Expression "COMPLETE=powershell "C:\path\to\binary.exe" -- ..."
&
.--%
This should instead be written something like this:
In addition, the instructions to install this in the profile are not correct:
This has the same inline env var problem, but also PowerShell tries to execute this line by line. It needs to be piped to
Out-String
:Debug Output
No response
The text was updated successfully, but these errors were encountered: