From c4bc6b6f09f7b1e92159028224c4325effa11ef5 Mon Sep 17 00:00:00 2001 From: Peter Ammon Date: Sun, 17 Nov 2024 16:47:59 -0800 Subject: [PATCH] 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. --- src/print_help.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/print_help.rs b/src/print_help.rs index ffae47d41..b45024f98 100644 --- a/src/print_help.rs +++ b/src/print_help.rs @@ -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), + _ => (), + } }