Skip to content
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

Piping into things that don't read all their input (e.g. head) should not result in an error. #232

Closed
clonezone opened this issue Aug 29, 2018 · 1 comment
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@clonezone
Copy link

E.g., with v0.6.0, bat --list-languages | head results in

…
thread 'main' panicked at 'failed printing to stdout: Broken pipe (os error 32)', libstd/io/stdio.rs:692:9
note: Run with `RUST_BACKTRACE=1` for a backtrace.

on both macOS and Linux.

@sharkdp
Copy link
Owner

sharkdp commented Aug 29, 2018

Thank you for reporting this.

We have fixed this for bat's general behavior (see #9 and 1f2bcf5), so things like bat README.md | head work fine, but we should also fix this when using --list-languages and --list-themes and probably the bat cache subcommand as well.

The strategy is simple. Just replace all print!(...) and println!(...) macros by write!(...)? and writeln!(...)?.

@sharkdp sharkdp added bug Something isn't working good first issue Good for newcomers labels Aug 29, 2018
mchlrhw added a commit to mchlrhw/bat that referenced this issue Aug 31, 2018
mchlrhw added a commit to mchlrhw/bat that referenced this issue Aug 31, 2018
sharkdp pushed a commit that referenced this issue Aug 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants