tokei
tokei copied to clipboard
Piping to head throwing error with --files options
When I try to pipe output from tokei to head
it throws an error:
~ tokei . --files | head
-------------------------------------------------------------------------------------------------------------------------------
Language Files Lines Code Comments Blanks
-------------------------------------------------------------------------------------------------------------------------------
Cabal 1 21 13 6 2
-------------------------------------------------------------------------------------------------------------------------------
./COMP3161/ass1/minhs1.cabal 21 13 6 2
-------------------------------------------------------------------------------------------------------------------------------
Haskell 12 836 648 65 123
-------------------------------------------------------------------------------------------------------------------------------
./COMP3161/Haskell.hs 13 6 4 3
Error: Os { code: 32, kind: BrokenPipe, message: "Broken pipe" }
From what I can see, this only seems to happen with the --files
option, as running tokei . --sort code | head
works fine.
This is with tokei --version
= tokei 8.0.1 compiled with serialization support: cbor, json, yaml, toml
Thank you for this issue! I'm also perplexed by this issue as even on master where output is done through a BufWriter still has this issue. It doesn't look like there was anything wrong in this particular case with the output so unless there's something I'm missing with how Rust interacts when a program is piped I guess we can just ignore this error and terminate.
Just tested this with tokei 12.1.2 and it's working fine. Should it be closed?
I used the linux kernel for testing.
tokei drivers/usb/dwc3/ --files | head
===============================================================================================================================================================
Language Files Lines Code Comments Blanks
===============================================================================================================================================================
C 20 15544 10757 2034 2753
---------------------------------------------------------------------------------------------------------------------------------------------------------------
drivers/usb/dwc3/trace.c 11 2 8 1
drivers/usb/dwc3/host.c 149 104 17 28
drivers/usb/dwc3/dwc3-haps.c 148 103 21 24
drivers/usb/dwc3/dwc3-of-simple.c 198 140 16 42
drivers/usb/dwc3/dwc3-keystone.c 226 169 12 45
@felipebalbi Thank you for checking!