tokei icon indicating copy to clipboard operation
tokei copied to clipboard

Piping to head throwing error with --files options

Open lukakerr opened this issue 6 years ago • 1 comments

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

lukakerr avatar Sep 15 '18 00:09 lukakerr

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.

XAMPPRocky avatar Oct 20 '18 13:10 XAMPPRocky

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 avatar Oct 28 '22 12:10 felipebalbi

@felipebalbi Thank you for checking!

XAMPPRocky avatar Oct 28 '22 13:10 XAMPPRocky