Does not properly detect cross-platform PowerShell (pwsh)
C-bugS-triage
### Please complete the following tasks
- [x] I have searched the [discussions](https://github.com/clap-rs/clap/discussions)
- [x] I have searched the [open](https://github.com/clap-rs/clap/issues) and [rejected](https://github.com/clap-rs/clap/issues?q=is%3Aissue+label%3AS-wont-fix+is%3Aclosed) issues
### Rust Version
rustc 1.98.0-nightly (beae78130 2026-06-09)
### Clap Version
4.6.1
### Minimal reproducible code
```rust
fn main() {
clap_complete::CompleteEnv::with_factory(Args::command).complete();
}
#[derive(clap::Parser)]
#[command]
struct Args;
```
### Steps to reproduce the bug with the above code
1. Install pwsh e.g., `brew install powershell` on macOS or linux.
2. Run: `pwsh`
3. `cargo add clap clap-complete -F clap/derivbe,clap-complete/unstable-dynamic`
4. Run: `COMPLETE=$(which pwsh) cargo run`. This is documented as supported in source. The main idea anyway is to show that, on any platform including Windows (powershell.exe is supported but basically EOL; pwsh is the way forward and has been for many years), `pwsh` is the executable you should be checking.
### Actual Behaviour
> error: unknown shell `pwsh`, expected one of `bash`, `elvish`, `fish`, `powershell`, `zsh`
### Expected Behaviour
Works like it would if the executable were `powershell` or for any other shell like `bash`.
### Additional Context
Based on <https://github.com/PowerShell/PowerShell/issues/12150> and my own testing, `SHELL` is unreliable. Seems only the initial shell sets it. Once set, it's never overwritten, which is partly why PowerShell closed it. Even if I start bash (default shell) then zsh on macOS, `SHELL` is still "bash".
Some other programs detect the parent process tree up to ~10 processes or so using `sysinfo` or similar.
### Debug Output
_No response_
0 条评论