summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Sago <ogham@users.noreply.github.com>2016-10-05 16:47:22 +0100
committerGitHub <noreply@github.com>2016-10-05 16:47:22 +0100
commit3f81300e21c35863570963c48e722463202b18dd (patch)
tree14de4b999783167d822c2685ed97d15628e546c2
parent6522337463264b544efbcd109f70e8334155495e (diff)
parent943ac87466b45067e59aec23e7b2b377e1173c20 (diff)
Merge pull request #118 from gemmarx/ignore_brokenpipe
Change to ignore broken pipe error
-rw-r--r--src/bin/main.rs14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/bin/main.rs b/src/bin/main.rs
index 491d793..914253e 100644
--- a/src/bin/main.rs
+++ b/src/bin/main.rs
@@ -2,7 +2,7 @@ extern crate exa;
use exa::Exa;
use std::env::args;
-use std::io::stdout;
+use std::io::{stdout, stderr, Write, ErrorKind};
use std::process::exit;
fn main() {
@@ -10,9 +10,17 @@ fn main() {
let mut stdout = stdout();
match Exa::new(&args, &mut stdout) {
- Ok(mut exa) => exa.run().expect("IO error"),
+ Ok(mut exa) => if let Err(e) = exa.run() {
+ match e.kind() {
+ ErrorKind::BrokenPipe => exit(0),
+ _ => {
+ writeln!(stderr(), "{}", e).unwrap();
+ exit(1);
+ },
+ };
+ },
Err(e) => {
- println!("{}", e);
+ writeln!(stderr(), "{}", e).unwrap();
exit(e.error_code());
},
};