diff options
author | Benjamin Nguyen <benjamin.van.nguyen@gmail.com> | 2023-07-04 14:43:08 +0700 |
---|---|---|
committer | Benjamin Nguyen <benjamin.van.nguyen@gmail.com> | 2023-07-04 14:43:08 +0700 |
commit | 36cb7e075dd87f85b62122cfd31057e01af675fb (patch) | |
tree | 8df473cef427bc1451a2f8609b2c0c39118b045d | |
parent | 202fae12b0cb4c0ce0a948060104df855e9ec3c5 (diff) |
don't panic when broken pipe
-rw-r--r-- | src/main.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs index e97fd2c..6d7ab04 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,7 +16,11 @@ use clap::CommandFactory; use context::{layout, Context}; use progress::{Indicator, IndicatorHandle, Message}; use render::{Engine, Flat, FlatInverted, Inverted, Regular}; -use std::{error::Error, io::stdout, process::ExitCode}; +use std::{ + error::Error, + io::{stdout, Write}, + process::ExitCode, +}; use tree::Tree; /// Operations to wrangle ANSI escaped strings. @@ -114,13 +118,13 @@ fn run() -> Result<(), Box<dyn Error>> { #[cfg(debug_assertions)] { if std::env::var_os("ERDTREE_DEBUG").is_none() { - println!("{output}"); + let _ = stdout().write(output.as_bytes()); } } #[cfg(not(debug_assertions))] { - println!("{output}"); + let _ = stdout().write(output.as_bytes()); } Ok(()) |