Move exit codes to 'internal' module

This commit is contained in:
sharkdp 2018-01-03 10:00:22 +01:00
parent 26ad7da347
commit 39fb41f05a
4 changed files with 11 additions and 8 deletions

View File

@ -100,3 +100,9 @@ fn expr_has_uppercase_char(expr: &Expr) -> bool {
_ => false, _ => false,
} }
} }
/// Exit code representing a general error
pub const EXITCODE_ERROR: i32 = 1;
/// Exit code representing that the process was killed by SIGINT
pub const EXITCODE_SIGINT: i32 = 130;

View File

@ -19,7 +19,6 @@ extern crate num_cpus;
extern crate regex; extern crate regex;
extern crate regex_syntax; extern crate regex_syntax;
mod exit_codes;
pub mod fshelper; pub mod fshelper;
pub mod lscolors; pub mod lscolors;
mod app; mod app;

View File

@ -6,8 +6,7 @@
// notice may not be copied, modified, or distributed except // notice may not be copied, modified, or distributed except
// according to those terms. // according to those terms.
use exit_codes; use internal::{FdOptions, EXITCODE_ERROR, EXITCODE_SIGINT};
use internal::FdOptions;
use lscolors::LsColors; use lscolors::LsColors;
use std::{fs, process}; use std::{fs, process};
@ -32,7 +31,7 @@ pub fn print_entry(entry: &PathBuf, config: &FdOptions, wants_to_quit: &Arc<Atom
if r.is_err() { if r.is_err() {
// Probably a broken pipe. Exit gracefully. // Probably a broken pipe. Exit gracefully.
process::exit(exit_codes::ERROR); process::exit(EXITCODE_ERROR);
} }
} }
@ -74,7 +73,7 @@ fn print_entry_colorized(
if wants_to_quit.load(Ordering::Relaxed) { if wants_to_quit.load(Ordering::Relaxed) {
write!(handle, "\n")?; write!(handle, "\n")?;
process::exit(exit_codes::SIGINT); process::exit(EXITCODE_SIGINT);
} }
} }

View File

@ -10,10 +10,9 @@ extern crate ctrlc;
use exec; use exec;
use fshelper; use fshelper;
use internal::{error, FdOptions}; use internal::{error, FdOptions, EXITCODE_SIGINT};
use output; use output;
use exit_codes;
use std::process; use std::process;
use std::path::PathBuf; use std::path::PathBuf;
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
@ -249,6 +248,6 @@ pub fn scan(path_vec: &[PathBuf], pattern: Arc<Regex>, config: Arc<FdOptions>) {
receiver_thread.join().unwrap(); receiver_thread.join().unwrap();
if wants_to_quit.load(Ordering::Relaxed) { if wants_to_quit.load(Ordering::Relaxed) {
process::exit(exit_codes::SIGINT); process::exit(EXITCODE_SIGINT);
} }
} }