NikitaIvanovV / catless

cat and less in one program
MIT License
5 stars 0 forks source link

gawk -> awk #1

Open Veraellyunjie opened 1 year ago

Veraellyunjie commented 1 year ago

First of all, I applause to you as catless is really missed in standard distributions and you fill the gap.

I tried catless via OpenBSD's awk which I don't know which awk flavor it is - but it definitely is not gawk - and it seems to work. So I'd like to ask you whether you target gawk or whether you target most awk flavors and whether you think it is reasonable and already safe to change the shebang to widely available #!/usr/bin/awk -f

NikitaIvanovV commented 1 year ago

Sorry for a long response.

I use PROCINFO variable here:

https://github.com/NikitaIvanovV/catless/blob/4ad51f90b57a59d6d3d9b6595af1fb4a204a4ed3/catless#L15-L16

And the GAWK manual says it's specific to GAWK:

https://www.gnu.org/software/gawk/manual/html_node/Auto_002dset.html#index-differences-in-awk-and-gawk-37

I added that line because I remember that less did not work as expected if it's exited it with the q key and the whole file has not been buffered yet. You can reproduce it by running git log | catless. Make sure to run it in a repo that has a rather long history of commits.

NikitaIvanovV commented 1 year ago

I just discovered that my fix has an undesirable side effect: if you run a command that takes a long time to finish (something like seq 10000), after quitting less, catless will still keep on going.

In the previous message, by "unexpected behavior" I meant they GAWK printer a fatal error message. But perhaps it's better than what we have know? Or maybe it's easier to rewrite catless in C? 😅 This way both problems will be easily fixed.