mirror of
https://github.com/sharkdp/fd
synced 2024-11-05 16:58:21 +00:00
Exit gracefully on broken pipe, fixes #24
This commit is contained in:
parent
641ca69b49
commit
2ea23c0000
1 changed files with 8 additions and 4 deletions
12
src/main.rs
12
src/main.rs
|
@ -138,12 +138,16 @@ fn print_entry(base: &Path, entry: &Path, config: &FdOptions) {
|
|||
}
|
||||
println!();
|
||||
} else {
|
||||
// Uncolorized output:
|
||||
// Uncolorized output
|
||||
|
||||
if config.path_display == PathDisplay::Absolute {
|
||||
print!("{}", ROOT_DIR);
|
||||
let prefix = if config.path_display == PathDisplay::Absolute { ROOT_DIR } else { "" };
|
||||
|
||||
let r = writeln!(&mut std::io::stdout(), "{}{}", prefix, path_str);
|
||||
|
||||
if r.is_err() {
|
||||
// Probably a broken pipe. Exit gracefully.
|
||||
process::exit(0);
|
||||
}
|
||||
println!("{}", path_str);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue