rustic icon indicating copy to clipboard operation
rustic copied to clipboard

`head` pipe causes panic

Open dimejo opened this issue 2 years ago • 2 comments

user@host:~$ rustic -r /srv/repo snapshots | head -n 2
enter repository password:
password is correct
 ID       | Time                | Host                | Tags   | Paths      | Files | Dirs | Size
----------+---------------------+---------------------+--------+------------+-------+------+------
thread 'main' panicked at 'Cannot print table to standard output : Broken pipe (os error 32)', /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/prettytable-rs-0.8.0/src/lib.rs:194:23
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

This seems to affect multiple/all commands. Tested and confirmed with check and ls aswell. Interestingly it doesn't happen with tail.

Do you need the backtrace?

dimejo avatar Jun 15 '22 09:06 dimejo

Thanks for the report! This seems in fact to be a problem with Rust's println! macro and all what depends on it, see e.g. https://github.com/rust-lang/rust/issues/46016

A solution is to use writeln! instead, but rustic also uses quite some external crates for the output which would need to be checked/fixed/replaced.

If anyone can help with this topic, I would be very grateful!

aawsome avatar Jun 15 '22 21:06 aawsome

Maybe it is a good idea to use https://crates.io/crates/console for the output? This could also allow to use colors or highlighting in the output.

aawsome avatar Jul 01 '22 09:07 aawsome