Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output differs (and is wrong) from cat on colored file from stark/Color-Scripts #771

Closed
ericonr opened this issue Dec 12, 2019 · 3 comments
Labels
upstream-error A bug in an upstream component

Comments

@ericonr
Copy link

ericonr commented Dec 12, 2019

I was taking a look at the colored terminal scripts from stark/Color-Scripts, and one of them was, instead of a script, a text file that had to be printed to STDOUT to be visualized. It was the crowns file. Using cat on it yields the correct result, but using bat yields a wrong result, both on Alacritty and Konsole, both with bash and fish, and with or without the -p flag for plain output.

The output from both commands can be seen in this asciinema.

EDIT:

bat version: 0.12.1

After a bit more investigating I tried running it with the pager disabled:

bat --paging=never crowns

which actually fixed the issue, even if there shouldn't have been a pager involved, because the output easily fit into the buffer.

By changing the PAGER environment variable to more, I got even weirder output, so it seems bat calls a pager anyway (unless paging is set to never), possibly with some flags that make it not page unless the output is big enough to need it, which seems unnecessary to me.

I will file a bug report with less and more developers, because both have weird output, even if they show the colors:

more crowns

or

less --RAW-CONTROL-CHARS crowns
@sharkdp
Copy link
Owner

sharkdp commented Dec 15, 2019

After a bit more investigating I tried running it with the pager disabled:

bat --paging=never crowns

👍

even if there shouldn't have been a pager involved, because the output easily fit into the buffer.

We always call the pager. The may then decide to exit early if the output fits on one screen. bat can not make that decision, as we want bat to be unbuffered ( we want to print one output line for each input line).

@sharkdp sharkdp added the upstream-error A bug in an upstream component label Dec 15, 2019
@sharkdp sharkdp closed this as completed Dec 15, 2019
@sharkdp
Copy link
Owner

sharkdp commented Dec 15, 2019

By the way: note that you can use bat -pp … to quickly disable the pager in case you experience problems with the pager in the future.

@ericonr
Copy link
Author

ericonr commented Dec 18, 2019

Ok, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
upstream-error A bug in an upstream component
Projects
None yet
Development

No branches or pull requests

2 participants