diff options
author | Benji Nguyen <45523555+solidiquis@users.noreply.github.com> | 2023-08-04 10:38:32 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-04 10:38:32 -0700 |
commit | 07b7017c09bfdcfb7e969e968c534267506f3716 (patch) | |
tree | e0647a15fb4fea28fc140617e12bb7ba063bee3d | |
parent | 490f7d253e446c6f99146248cf0bbf6f3d4ae886 (diff) | |
parent | 29282b403c1f5c9e74e84b469fd7f866c164b462 (diff) |
Merge pull request #227 from solidiquis/broken-pipe
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..fb203a7 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 _ = writeln!(stdout(), "{output}"); } } #[cfg(not(debug_assertions))] { - println!("{output}"); + let _ = writeln!(stdout(), "{output}"); } Ok(()) |