From 5e78a43242fe46f10213277ff3a7a7103a891183 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 14 Feb 2018 18:29:46 +0100 Subject: [PATCH] Fix for broken pipe panics --- bin/domain/imag-habit/src/main.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/bin/domain/imag-habit/src/main.rs b/bin/domain/imag-habit/src/main.rs index d9263dd2..bcce7459 100644 --- a/bin/domain/imag-habit/src/main.rs +++ b/bin/domain/imag-habit/src/main.rs @@ -47,11 +47,14 @@ extern crate libimagutil; extern crate libimagentrylist; extern crate libimaginteraction; +use std::io::Write; use std::process::exit; use libimagrt::runtime::Runtime; use libimagrt::setup::generate_runtime_setup; use libimagerror::trace::{MapErrTrace, trace_error}; +use libimagerror::exit::ExitUnwrap; +use libimagerror::io::ToExitCode; use libimaghabit::store::HabitStore; use libimaghabit::habit::builder::HabitBuilder; use libimaghabit::habit::HabitTemplate; @@ -389,6 +392,7 @@ fn show(rt: &Runtime) { vec![date, comm] } + let mut out = ::std::io::stdout(); let _ = rt .store() @@ -403,12 +407,15 @@ fn show(rt: &Runtime) { let recur = habit.habit_recur_spec().map_err_trace_exit_unwrap(1); let comm = habit.habit_comment().map_err_trace_exit_unwrap(1); - println!("{i} - {name}\nBase : {b},\nRecurrence: {r}\nComment : {c}\n", + let _ = writeln!(out, + "{i} - {name}\nBase : {b},\nRecurrence: {r}\nComment : {c}\n", i = i, name = name, b = basedate, r = recur, - c = comm); + c = comm) + .to_exit_code() + .unwrap_or_exit(); let instances_iter = habit .linked_instances()