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

Can't use bat at all! (Error: Use of bat as a pager is disallowed...) #1413

Closed
cansurmeli opened this issue Nov 30, 2020 · 8 comments
Closed
Labels
bug Something isn't working
Milestone

Comments

@cansurmeli
Copy link

What version of bat are you using?
bat 0.17.1

Describe the bug you encountered:

Whenever I use bat, I'm shown the following error message:

[bat error]: Use of bat as a pager is disallowed in order to avoid infinite recursion problems

I believe this started happening after a certain update but can't exactly pinpoint which one. I've uninstalled and reinstalled bat again but with no luck.

What did you expect to happen instead?
For bat to display the contents as usual.

How did you install bat?
Homebrew


system

$ uname -srm
Darwin 20.1.0 x86_64

$ sw_vers
ProductName: macOS
ProductVersion: 11.0.1
BuildVersion: 20B29

bat

$ bat --version
bat 0.17.1

$ env
PAGER=bat

bat_config

bat_wrapper

No wrapper script for 'bat'.

bat_wrapper_function

No wrapper function for 'bat'.

No wrapper function for 'cat'.

tool

$ less --version
less 487 (POSIX regular expressions)

@cansurmeli cansurmeli added the bug Something isn't working label Nov 30, 2020
@sudo-nice
Copy link

That's intentional, see #1343
Personally, I don't like this restriction too (but it's not hard to overcome).

@sharkdp
Copy link
Owner

sharkdp commented Dec 1, 2020

That's intentional, see #1343

Hm. Kind of, but not to the extent documented here, actually. What we really want to avoid is infinite recursion (bat calls bat as pager, which calls bat as pager, …). See #1334.

What I didn't foresee is that users want to set PAGER=bat to use bat as a pager in other contexts.

So what we probably should do instead:

  • Allow PAGER=bat, but ignore the setting in bat and simply default to less. Unless of course, BAT_PAGER or --pager is used to overwrite the value of PAGER.
  • Disallow the usage of bat within BAT_PAGER and --pager.

@Enselic
Copy link
Collaborator

Enselic commented Dec 1, 2020

@cansurmeli Before the fix is out, as a workaround, you can pass --paging=never to bat.

I.e. this fails in 0.17.1:
PAGER=bat bat file.txt

But this works:
PAGER=bat bat --paging=never file.txt

@sharkdp
Copy link
Owner

sharkdp commented Dec 1, 2020

Another workaround would be to use --pager="less -FRX". You can also add that line to the bats config file.

@Enselic
Copy link
Collaborator

Enselic commented Dec 1, 2020

@sharkdp Did you see my PR with PagerSource? Seems to me as if that approach could be useful to implement the new behavior you propose here.

@cansurmeli
Copy link
Author

Ok, I get the picture now. I saw #1343 & #1334 before but didn't quite understand the situation.

In the meantime, --paging=never suffices as a workaround. Thanks for all the suggestions.

thezeroalpha added a commit to thezeroalpha/dotfiles that referenced this issue Dec 1, 2020
Apparently `bat` isn't supposed to be set as a pager, even though it has
paging capabilities. So they added a 'feature' that makes bat crash when
it's set as a pager. I have no fucking clue why they'd do that.
sharkdp/bat#1413
thezeroalpha added a commit to thezeroalpha/dotfiles that referenced this issue Dec 16, 2020
Apparently `bat` isn't supposed to be set as a pager, even though it has
paging capabilities. So they added a 'feature' that makes bat crash when
it's set as a pager. I have no fucking clue why they'd do that.
sharkdp/bat#1413

Former-commit-id: d1b5392
@Enselic
Copy link
Collaborator

Enselic commented Dec 30, 2020

I will happily fix this bug once #1402 is merged, because it should be very simple, assuming the current refactoring proposal in that PR survives code review.

@sharkdp sharkdp added this to the v0.18.0 milestone Jan 9, 2021
@Enselic Enselic mentioned this issue Jan 10, 2021
Enselic added a commit to Enselic/bat that referenced this issue Jan 10, 2021
…r is disallowed...)

Fixed by implementing the proposal by sharkdp:

* Allow PAGER=bat, but ignore the setting in bat and simply default to
  less. Unless of course, BAT_PAGER or --pager is used to overwrite the
  value of PAGER.

* Disallow the usage of bat within BAT_PAGER and --pager.
Enselic added a commit to Enselic/bat that referenced this issue Jan 10, 2021
sharkdp pushed a commit that referenced this issue Jan 11, 2021
gwarf added a commit to gwarf/dotfiles that referenced this issue Jan 12, 2021
thezeroalpha added a commit to thezeroalpha/dotfiles that referenced this issue Jan 25, 2021
Apparently `bat` isn't supposed to be set as a pager, even though it has
paging capabilities. So they added a 'feature' that makes bat crash when
it's set as a pager. I have no fucking clue why they'd do that.
sharkdp/bat#1413

Former-commit-id: d1b5392
@sharkdp
Copy link
Owner

sharkdp commented Feb 28, 2021

Bugfix released in bat v0.18.

thezeroalpha added a commit to thezeroalpha/dotfiles that referenced this issue May 11, 2021
Apparently `bat` isn't supposed to be set as a pager, even though it has
paging capabilities. So they added a 'feature' that makes bat crash when
it's set as a pager. I have no fucking clue why they'd do that.
sharkdp/bat#1413

Former-commit-id: d1b5392
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants