mirror of
https://github.com/sharkdp/fd
synced 2024-10-02 22:13:31 +00:00
Exit gracefully on broken pipe, fixes #24
This commit is contained in:
parent
641ca69b49
commit
2ea23c0000
12
src/main.rs
12
src/main.rs
|
@ -138,12 +138,16 @@ fn print_entry(base: &Path, entry: &Path, config: &FdOptions) {
|
||||||
}
|
}
|
||||||
println!();
|
println!();
|
||||||
} else {
|
} else {
|
||||||
// Uncolorized output:
|
// Uncolorized output
|
||||||
|
|
||||||
if config.path_display == PathDisplay::Absolute {
|
let prefix = if config.path_display == PathDisplay::Absolute { ROOT_DIR } else { "" };
|
||||||
print!("{}", ROOT_DIR);
|
|
||||||
|
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