VladimirMarkelov / ttdl

TTDL - Terminal Todo List Manager
MIT License
210 stars 17 forks source link

Panics when output is piped to head & family #59

Closed SevereOverfl0w closed 2 years ago

SevereOverfl0w commented 2 years ago
❯ ttdl list | head -1
 # D P Created    Finished   Due        Subject
Failed to print to stdout: Os { code: 32, kind: BrokenPipe, message: "Broken pipe" }
Failed to print to stdout: Os { code: 32, kind: BrokenPipe, message: "Broken pipe" }
...
thread 'main' panicked at 'failed printing to stdout: Broken pipe (os error 32)', library/std/src/io/stdio.rs:1017:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
VladimirMarkelov commented 2 years ago

Thanks for the report. I cannot reproduce it on Windows, it does not panics. Interesting.

PS C:\docs> ttdl | coreutils.exe head -1
 # D P Created    Due        Subject
PS C:\docs> ttdl | coreutils.exe head -2
 # D P Created    Due        Subject
-------------------------------------

I need to run a Linux machine somewhere to test.

VladimirMarkelov commented 2 years ago

I redesigned the output mechanism in 3.4.1. On Ubuntu 22, the new binary works without panicking.

SevereOverfl0w commented 2 years ago

There's no panic, but there is still Failed to print to stdout: Os { code: 32, kind: BrokenPipe, message: "Broken pipe" } which I wouldn't expect either. For example, cat foo.txt | head -1 wouldn't error that the remaining lines to stdout were closed.

VladimirMarkelov commented 2 years ago

Ouch. I found a call that I have missed. I'll fix the call and publish a new release.

VladimirMarkelov commented 2 years ago

3.4.2 includes another fix for "broken pipe"

SevereOverfl0w commented 2 years ago

Works on my machine! Thanks!