From df81a24dae58b85afc96587a8764aaa52aeb9464 Mon Sep 17 00:00:00 2001 From: Benjamin Sago Date: Sat, 10 Oct 2020 01:11:22 +0100 Subject: [PATCH] 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. --- src/bin/main.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/bin/main.rs b/src/bin/main.rs index e070d46..9b36526 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -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; }