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

panic when piping to head #79

Closed
Witcher01 opened this issue Dec 30, 2021 · 1 comment · Fixed by #82
Closed

panic when piping to head #79

Witcher01 opened this issue Dec 30, 2021 · 1 comment · Fixed by #82
Labels
enhancement New feature or request

Comments

@Witcher01
Copy link
Contributor

Piping the output of rbw list to head results in a panic:

$ rbw list | head -n 1
<first entry>
thread 'main' panicked at 'failed printing to stdout: Broken pipe (os error 32)', library/std/src/io/stdio.rs:935:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Piping it into tail doesn't produce a panic, probably due to the pipe being closed after instead of before rbw is done writing to it.

I haven't looked into it much, but this instance of the panic seems to be cause by the following println! macro call:

println!("{}", values.join("\t"));

A fix would be to replace this with a write!, which returns an error that can be handled.

If a fix is desired I might have time to look into it.

@doy doy added the enhancement New feature or request label Feb 10, 2022
@doy
Copy link
Owner

doy commented Feb 10, 2022

yeah, fixing this seems like a good idea - feel free to submit a pull request!

Witcher01 added a commit to Witcher01/rbw that referenced this issue Feb 13, 2022
Piping stdout to something like `head`, which closes rbw's stdout before
it's done writing everything, causes a panic.
The panic is circumvented by using `writeln!` instead of `println!` and
ignoring the error when it's of kind `BrokenPipe`.
Closes doy#79
@doy doy closed this as completed in #82 Feb 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants