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,
}
}
/// 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_syntax;
mod exit_codes;
pub mod fshelper;
pub mod lscolors;
mod app;

View File

@ -6,8 +6,7 @@
// notice may not be copied, modified, or distributed except
// according to those terms.
use exit_codes;
use internal::FdOptions;
use internal::{FdOptions, EXITCODE_ERROR, EXITCODE_SIGINT};
use lscolors::LsColors;
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() {
// 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) {
write!(handle, "\n")?;
process::exit(exit_codes::SIGINT);
process::exit(EXITCODE_SIGINT);
}
}

View File

@ -10,10 +10,9 @@ extern crate ctrlc;
use exec;
use fshelper;
use internal::{error, FdOptions};
use internal::{error, FdOptions, EXITCODE_SIGINT};
use output;
use exit_codes;
use std::process;
use std::path::PathBuf;
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();
if wants_to_quit.load(Ordering::Relaxed) {
process::exit(exit_codes::SIGINT);
process::exit(EXITCODE_SIGINT);
}
}