From 872b300b9c2e14cab86a6efaf5200cb204c84a66 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 14 Feb 2018 23:33:35 +0100 Subject: [PATCH] Fix broken pipe panics --- bin/core/imag-gps/src/main.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/bin/core/imag-gps/src/main.rs b/bin/core/imag-gps/src/main.rs index 0a1dafa8..56423286 100644 --- a/bin/core/imag-gps/src/main.rs +++ b/bin/core/imag-gps/src/main.rs @@ -42,6 +42,7 @@ extern crate libimagutil; extern crate libimagerror; extern crate libimagstore; +use std::io::Write; use std::process::exit; use std::path::PathBuf; use std::str::FromStr; @@ -54,6 +55,8 @@ use libimagrt::setup::generate_runtime_setup; use libimagrt::runtime::Runtime; use libimagutil::warn_exit::warn_exit; use libimagerror::trace::MapErrTrace; +use libimagerror::exit::ExitUnwrap; +use libimagerror::io::ToExitCode; use libimagstore::storeid::IntoStoreId; mod ui; @@ -141,8 +144,10 @@ fn remove(rt: &Runtime) { }) .map_err_trace_exit_unwrap(1); // The parsing of the deleted values failed + let mut out = ::std::io::stdout(); + if scmd.is_present("print-removed") { - println!("{}", removed_value); + let _ = writeln!(out, "{}", removed_value).to_exit_code().unwrap_or_exit(); } } @@ -169,6 +174,7 @@ fn get(rt: &Runtime) { exit(1) }); - println!("{}", value); + let mut out = ::std::io::stdout(); + let _ = writeln!(out, "{}", value).to_exit_code().unwrap_or_exit(); }