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

Since recent update, short files that do not require paging are displayed and then lost #887

Closed
glucas opened this issue Mar 24, 2020 · 14 comments
Labels
bug Something isn't working help wanted Extra attention is needed upstream-error A bug in an upstream component windows Issue is related to the Windows build of bat
Milestone

Comments

@glucas
Copy link

glucas commented Mar 24, 2020

I'm using bat on Windows 10, installed via scoop. After updating yesterday to the latest release, I'm seeing a change in behavior. When I bat a small file (that does not require paging), it looks like the terminal is cleared, the output is shown, and then things reset and I've lost the output.

With a longer file I get the normal paging behavior and things seem fine.

Things were working as expected prior to this latest release.

@glucas glucas added the bug Something isn't working label Mar 24, 2020
@glucas
Copy link
Author

glucas commented Mar 24, 2020

See screenshot: cat displays as expected; bat flashes the content then it is gone:
image

@sharkdp
Copy link
Owner

sharkdp commented Mar 24, 2020

Thank you for reporting this. That looks like yet another problem with less.

Could you please tell us which version of less you are running?

less --version

As a workaround, you can disable paging by adding

--paging=never

to your bat config file.

@sharkdp
Copy link
Owner

sharkdp commented Mar 24, 2020

The behavior that is new since the last release is the following: #786

@sharkdp
Copy link
Owner

sharkdp commented Mar 24, 2020

partly related: #860

@sharkdp sharkdp added the windows Issue is related to the Windows build of bat label Mar 24, 2020
@sharkdp
Copy link
Owner

sharkdp commented Apr 11, 2020

@glucas Any update on this? I'd really like to fix this if this is a bug.

@sharkdp sharkdp added this to the v0.14 milestone Apr 11, 2020
@sharkdp
Copy link
Owner

sharkdp commented Apr 15, 2020

I've looked into this myself. I can reproduce this on Windows with less 551.

The problem is the following:

We used to call less with

less --RAW-CONTROL-CHARS --quit-if-one-screen --no-init

We only passed --no-init because there was a bug with previous versions of less which required the use of --no-init in combination with --quit-if-one-screen to prevent this "no output" issue from happening.

Since bat 0.13, we omit the --no-init option if we can detect that the version of less is higher than or equal to 530. We did that because --no-init breaks mouse support and because less 530 fixed the above-mentioned bug. However, it seems that this bug was not fixed on Windows!

If I call

less --RAW-CONTROL-CHARS --quit-if-one-screen small-file

on a small file, I don't see any output (only a small flash, as described above). On Linux, everything works fine.

Maybe @gwsw could have a look? (only if you find the time!)

@sharkdp sharkdp added the upstream-error A bug in an upstream component label Apr 15, 2020
@dugdun
Copy link

dugdun commented Apr 15, 2020

Hi @sharkdp, I am running bat 0.13.0 on MacOS Catalina and I am having similar issues as to what is reported here. Small files not needing the pager will not show up (although the screen flickers like it's going to show the contents, but just returns back out to a prompt.

If I use the --pager=none option small files not needing the pager will show as expected.

$ bat --version
bat 0.13.0
$ less --version
less 487 (POSIX regular expressions)
Copyright (C) 1984-2016  Mark Nudelman

less comes with NO WARRANTY, to the extent permitted by law.
For information about the terms of redistribution,
see the file named README in the less distribution.
Homepage: http://www.greenwoodsoftware.com/less

If this should be a new issue let me know but since they seemed similar enough I thought I would start here.

@sharkdp
Copy link
Owner

sharkdp commented Apr 15, 2020

If this should be a new issue let me know but since they seemed similar enough I thought I would start here.

@dugdun Thank you for reporting this. It would be great if you could open a new bug report using the corresponding issue template: https://github.com/sharkdp/bat/issues/new?assignees=&labels=bug&template=bug_report.md&title=

@dugdun
Copy link

dugdun commented Apr 15, 2020

It would be great if you could open a new bug report

@sharkdp I've filed a new bug report. Sorry for cluttering this issue.

Thanks for the awesome tool!

@gwsw
Copy link

gwsw commented Apr 17, 2020

Could you try less v558 at https://github.com/gwsw/less and verify whether that fixes the problem for you?

@sharkdp
Copy link
Owner

sharkdp commented Apr 18, 2020

@gwsw Thank you very much for this update!

I tried building v558 from source in my VirtualBox Windows setup, but gave up after an hour or so. I'm not really familiar with the Windows Visual C++ world. If anyone could build a amd64 binary for me, I'm happy to try this out.

If this fixes the bug on Windows, we can change bats behavior to only omit --no-init if less_version >= 558. Something like:

Some(version) if (version < 530 || (cfg!(windows) && version < 558)) => {
    p.arg("--no-init");
}

@gwsw
Copy link

gwsw commented Apr 19, 2020

I found a problem with less v558 and have updated it. Please used v559 for your testing.

@sharkdp sharkdp added the help wanted Extra attention is needed label Apr 19, 2020
@sharkdp
Copy link
Owner

sharkdp commented Apr 21, 2020

@gwsw Thank you very much for your support. I'm going to assume that the bug is fixed in 559, so I updated the logic accordingly: 864656b

If someone is able to test this, any support would be greatly appreciated. In the meantime, I'm going to close this ticket. The issue will definitely be solved for less 551.

@sharkdp sharkdp closed this as completed Apr 21, 2020
pull bot pushed a commit to IMULMUL/bat that referenced this issue Apr 21, 2020
We used to call `less` with
``` bash
less --RAW-CONTROL-CHARS --quit-if-one-screen --no-init
```
We only passed `--no-init` because there was a bug with previous versions
of `less` which required the use of `--no-init` in combination with
`--quit-if-one-screen` to prevent this "no output" issue from happening.

Since bat 0.13, [we omit the `--no-init` option](https://github.com/sharkdp/bat/blob/0ecc94956b88beed27ca13a130c8ba09f1a220d8/src/output.rs#L85-L97)
if we can detect that the version of `less` is higher than or equal to 530. We
did that because `--no-init` breaks mouse support and because [less 530 fixed
the above-mentioned bug](http://www.greenwoodsoftware.com/less/news.530.html).
However, it seems that this bug was *not* fixed on Windows!

According to @gwsw, the issue should be fixed with less 559 on Windows.

closes sharkdp#887
@sharkdp
Copy link
Owner

sharkdp commented Apr 22, 2020

This has been fixed in bat v0.14.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed upstream-error A bug in an upstream component windows Issue is related to the Windows build of bat
Projects
None yet
Development

No branches or pull requests

4 participants