1
0
mirror of https://github.com/sharkdp/bat.git synced 2025-03-13 22:28:26 +00:00

Merge 1455d7d3adce872e9b32ef47674660708f1fae7c into ccb1d78b22181505aa6e6de024f1b3d5762c0182

This commit is contained in:
Ryan Leung 2018-05-06 16:34:37 +00:00 committed by GitHub
commit 88db823154
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -540,9 +540,29 @@ fn run() -> Result<()> {
})?;
if let Some(files) = app_matches.values_of("FILE") {
let mut exit = false;
for file in files {
let line_changes = get_git_diff(&file.to_string());
print_file(&options, theme, &assets.syntax_set, file, &line_changes)?;
let res = print_file(&options, theme, &assets.syntax_set, file, &line_changes);
if let Err(error) = res {
if match error {
Error(ErrorKind::Io(ref io_error), _)
if io_error.kind() == io::ErrorKind::BrokenPipe =>
{
true
}
_ => {
exit = true;
eprintln!("{}: {}: {}", Red.paint("[bat error]"), file, error);
false
}
} {
return Err(error);
}
}
}
if exit {
process::exit(1);
}
}
}