Unverified Commit 49c1e8c9 authored by Jared Baur's avatar Jared Baur
Browse files

switch-to-configuration-ng: ensure die() always exits with non-zero code

parent 88a11a0d
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -123,7 +123,14 @@ impl From<&Action> for &'static str {
// Allow for this switch-to-configuration to remain consistent with the perl implementation.
// Perl's "die" uses errno to set the exit code: https://perldoc.perl.org/perlvar#%24%21
fn die() -> ! {
    std::process::exit(std::io::Error::last_os_error().raw_os_error().unwrap_or(1));
    let code = match std::io::Error::last_os_error().raw_os_error().unwrap_or(1) {
        // Ensure that even if errno did not point to a helpful error code, we still have a
        // non-zero exit code
        0 => 1,
        other => other,
    };

    std::process::exit(code);
}

fn parse_os_release() -> Result<HashMap<String, String>> {