diff options
author | Benjamin Sago <ogham@bsago.me> | 2020-10-10 01:11:22 +0100 |
---|---|---|
committer | Benjamin Sago <ogham@bsago.me> | 2020-10-10 01:11:22 +0100 |
commit | df81a24dae58b85afc96587a8764aaa52aeb9464 (patch) | |
tree | 44c4c32d0e4b22d75d230de42d98d6886a47f781 | |
parent | ee898bef8d02cf28d1d8552995e5339c5c2994ef (diff) |
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.
-rw-r--r-- | src/bin/main.rs | 14 |
1 files 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; } |