Completion fails past the first argument when the binary name contains a hyphen
Author: joefernerCreated Sep 20, 2026Updated Sep 20, 2026
LabelsC-bugS-triage
Please complete the following tasks
- I have searched the discussions
- I have searched the open and rejected issues
Rust Version
rustc 1.96.0 (ac68faa20 2026-05-25)
Clap Version
4.6.6
Minimal reproducible code
use clap::{Arg, Command};
use clap_complete::{generate, Shell};
fn main() {
let mut cmd = Command::new("my-tool")
.subcommand(Command::new("build").arg(Arg::new("target").long("target")));
generate(Shell::Bash, &mut cmd, "my-tool", &mut std::io::stdout());
}Steps to reproduce the bug with the above code
- Put that snippet in a new crate with
clapandclap_complete. cargo run > my-tool.bashsource my-tool.bash- Type
my-tool build --and press Tab twice. - Nothing appears. Expected
--target --help. - Change both
my-toolstrings tomytool, repeat — now the options appear.
Actual Behaviour
Nothing appears when pressing Tab twice.
Expected Behaviour
Expected to see --target --help
Additional Context
No response
Debug Output
No response
Source: clap-rs/clap