Use 0 and 1 rather than EXIT_SUCCESS/FAILURE

It doesn't seem right to use the EXIT_SUCCESS constant in one place, and a hard-coded 2 in another. What if they overlap?

Changing the success value to 0 should be OK, though, because the standard defines 0 as success, regardless of whether EXIT_SUCCESS is 0 or not.

Also, the values have become i32s. The Rust function std::process::exit takes an i32, so there's not much point using anything else.
This commit is contained in:
Benjamin Sago 2020-10-10 01:11:22 +01:00
parent ee898bef8d
commit df81a24dae

View File

@ -74,12 +74,14 @@ pub fn configure_logger() {
}
extern crate libc;
#[allow(trivial_numeric_casts)]
mod exits {
use libc::{self, c_int};
pub const SUCCESS: c_int = libc::EXIT_SUCCESS;
pub const RUNTIME_ERROR: c_int = libc::EXIT_FAILURE;
pub const OPTIONS_ERROR: c_int = 3 as c_int;
/// Exit code for when exa runs OK.
pub const SUCCESS: i32 = 0;
/// Exit code for when there was at least one I/O error during execution.
pub const RUNTIME_ERROR: i32 = 1;
/// Exit code for when the command-line options are invalid.
pub const OPTIONS_ERROR: i32 = 3;
}