mirror of
https://github.com/sharkdp/fd.git
synced 2024-09-30 05:51:29 +02:00
Move exit codes to 'internal' module
This commit is contained in:
parent
26ad7da347
commit
39fb41f05a
@ -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;
|
||||||
|
@ -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;
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user