Clean up print_help

`print_help` is a hacky-wacky function used to support the `--help` command
of `fish_key_reader` and others. The Rust version panics on an error; fix
that and make it print more useful help messages.
This commit is contained in:
Peter Ammon 2024-11-17 16:47:59 -08:00
parent 262e2d5fe6
commit c4bc6b6f09
No known key found for this signature in database

View File

@ -11,8 +11,13 @@ pub fn print_help(command: &str) {
cmdline.push("__fish_print_help ");
cmdline.push(command);
Command::new("fish")
match Command::new("fish")
.args([OsStr::new("-c"), &cmdline])
.spawn()
.expect(HELP_ERR);
.and_then(|mut c| c.wait())
{
Ok(status) if !status.success() => eprintln!("{}", HELP_ERR),
Err(e) => eprintln!("{}: {}", HELP_ERR, e),
_ => (),
}
}