Correct exit codes (#202)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
* Changed exit code on ctrl-c to 130 to match specification * Changed exit code when stdout errors. 1 for general error.
authored by Dock · committed by David Peter · parent 2bc72a5 · Browse files · 2 files·+26 added−23 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+26 added−23 removed
- other:+26 added−23 removed
Provenance
- Commit
4d66c84- Tree
4e330c5- Author
Dock <dockconnellyoneal@gmail.com>- Committer
David Peter <sharkdp@users.noreply.github.com>- Parent
2bc72a5
2 files changed+26 added−23 removed
modified:src/output.rs+5 added-2 removed
18 unmodified lines19 use std::os::unix::fs::PermissionsExt;20 21 use ansi_term;22 23+const EXIT_CODE_ERROR: i32 = 1;24+const EXIT_CODE_SIGINT: i32 = 130;25+26 pub fn print_entry(entry: &PathBuf, config: &FdOptions, wants_to_quit: &Arc<AtomicBool>) {27 let path = entry.strip_prefix(".").unwrap_or(entry);28 29 let r = if let Some(ref ls_colors) = config.ls_colors {3 unmodified lines33 };34 35 if r.is_err() {36 // Probably a broken pipe. Exit gracefully.34- process::exit(0);37+ process::exit(EXIT_CODE_ERROR);38 }39 }40 41 fn print_entry_colorized(33 unmodified lines75 };76 77 if wants_to_quit.load(Ordering::Relaxed) {78 write!(handle, "\n")?;76- process::exit(0);79+ process::exit(EXIT_CODE_SIGINT);80 }81 }82 83 if config.null_separator {53 unmodified linesmodified:Cargo.lock+21 added-21 removed
1-[root]2-name = "fd-find"3-version = "6.1.0"4-dependencies = [5- "ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",6- "atty 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",7- "clap 2.29.0 (registry+https://github.com/rust-lang/crates.io-index)",8- "ctrlc 3.0.3 (registry+https://github.com/rust-lang/crates.io-index)",9- "diff 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",10- "ignore 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",11- "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",12- "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",13- "libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)",14- "num_cpus 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)",15- "regex 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",16- "regex-syntax 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",17- "tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",18- "version_check 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",19- "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",20-]21-1 [[package]]2 name = "aho-corasick"3 version = "0.6.4"4 source = "registry+https://github.com/rust-lang/crates.io-index"71 unmodified lines76 version = "0.1.11"77 source = "registry+https://github.com/rust-lang/crates.io-index"78 79 [[package]]80+name = "fd-find"81+version = "6.1.0"82+dependencies = [83+ "ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",84+ "atty 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",85+ "clap 2.29.0 (registry+https://github.com/rust-lang/crates.io-index)",86+ "ctrlc 3.0.3 (registry+https://github.com/rust-lang/crates.io-index)",87+ "diff 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",88+ "ignore 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",89+ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",90+ "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",91+ "libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)",92+ "num_cpus 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)",93+ "regex 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",94+ "regex-syntax 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",95+ "tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",96+ "version_check 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",97+ "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",98+]99+100+[[package]]101 name = "fnv"102 version = "1.0.6"103 source = "registry+https://github.com/rust-lang/crates.io-index"104 294 unmodified lines