Skip to content

fix: ignore broken pipes when writing to terminal #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

BapRx
Copy link

@BapRx BapRx commented Feb 21, 2025

I registered a lot of repositories and I'd like to be able to pipe the output of multigit to other programs to process the output. For example:

❯ multigit list | head -n1
/Users/baprx/example-repo

thread 'main' panicked at library/std/src/io/stdio.rs:1123:9:
failed printing to stdout: Broken pipe (os error 32)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

With this PR I'm able to do this.
Broken pipes in Rust CLI tools is a well known issue that affects a lot of tools. cf rust's issue tracker: rust-lang/rust#46016

Changes:

  • fix: use writeln instead of println to catch broken pipe errors.
  • chore: switch to colored lib instead of colored_markup which is maintained and more straightforward.

chore: switch to colored lib instead of colored_markup which is maintained and more straightforward.

Broken pipes in Rust CLI tools is a well known issue that affects a lot of tools. cf rust's issue tracker: rust-lang/rust#46016
@schwa
Copy link
Owner

schwa commented Feb 21, 2025

Thanks for the PR - I'd be willing to consider this if it were two PRs - one with the writeln change and one with the colored change. I maintain colored_markup so I am less concerned about maintenance.

@BapRx
Copy link
Author

BapRx commented Feb 21, 2025

Thanks for the PR - I'd be willing to consider this if it were two PRs - one with the writeln change and one with the colored change. I maintain colored_markup so I am less concerned about maintenance.

I don't see how to split this PR since the calls which produce the broken pipe are println_markup from colored_markup. Please tell me if you see a way to do so, I'm not experienced with Rust 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants