diff --git a/src/util.rs b/src/util.rs index d4702e5..34c07c8 100644 --- a/src/util.rs +++ b/src/util.rs @@ -307,14 +307,16 @@ pub fn editor_cmd() -> impl Iterator> + Clone { .arg("core.editor") .output() { - let mut output = output.stdout; - // the last byte should be a nul - assert_eq!(Some(0), output.pop()); - - if !output.is_empty() { - let cmd = split_whitespace(&output); - if !cmd.is_empty() { - return cmd; + if output.status.success() { + let mut output = output.stdout; + // the last byte should be a nul + assert!(matches!(output.pop(), Some(0) | None)); + + if !output.is_empty() { + let cmd = split_whitespace(&output); + if !cmd.is_empty() { + return cmd; + } } } }