Fix for broken pipe panics

This commit is contained in:
Matthias Beyer 2018-02-14 18:29:46 +01:00
parent c2dfb2ef52
commit 5e78a43242

View file

@ -47,11 +47,14 @@ extern crate libimagutil;
extern crate libimagentrylist; extern crate libimagentrylist;
extern crate libimaginteraction; extern crate libimaginteraction;
use std::io::Write;
use std::process::exit; use std::process::exit;
use libimagrt::runtime::Runtime; use libimagrt::runtime::Runtime;
use libimagrt::setup::generate_runtime_setup; use libimagrt::setup::generate_runtime_setup;
use libimagerror::trace::{MapErrTrace, trace_error}; use libimagerror::trace::{MapErrTrace, trace_error};
use libimagerror::exit::ExitUnwrap;
use libimagerror::io::ToExitCode;
use libimaghabit::store::HabitStore; use libimaghabit::store::HabitStore;
use libimaghabit::habit::builder::HabitBuilder; use libimaghabit::habit::builder::HabitBuilder;
use libimaghabit::habit::HabitTemplate; use libimaghabit::habit::HabitTemplate;
@ -389,6 +392,7 @@ fn show(rt: &Runtime) {
vec![date, comm] vec![date, comm]
} }
let mut out = ::std::io::stdout();
let _ = rt let _ = rt
.store() .store()
@ -403,12 +407,15 @@ fn show(rt: &Runtime) {
let recur = habit.habit_recur_spec().map_err_trace_exit_unwrap(1); let recur = habit.habit_recur_spec().map_err_trace_exit_unwrap(1);
let comm = habit.habit_comment().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, i = i,
name = name, name = name,
b = basedate, b = basedate,
r = recur, r = recur,
c = comm); c = comm)
.to_exit_code()
.unwrap_or_exit();
let instances_iter = habit let instances_iter = habit
.linked_instances() .linked_instances()