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

Losing bat when looking up man pages #3085

Open
SamuelLarkin opened this issue Sep 18, 2024 · 2 comments
Open

Losing bat when looking up man pages #3085

SamuelLarkin opened this issue Sep 18, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@SamuelLarkin
Copy link

SamuelLarkin commented Sep 18, 2024

What steps will reproduce the bug?
Following the suggested MANPAGER replacement here

sh -c 'col -bx | bat --language man --plain'

I get an error trying to read some man page

man quota

What happens?

sh: 1: bat: Permission denied
man: command exited with status 127: sed -e '/^[[:space:]]*$/{ N; /^[[:space:]]*\n[[:space:]]*$/D; }' | LESS=-ix8RmPm Manual page quota(1) ?ltline %lt?L/%L.:byte %bB?s/%s..?e (END):?pB %pB\%.. (press h for help or q to quit)$PM Manual page quota(1) ?ltline %lt?L/%L.:byte %bB?s/%s..?e (END):?pB %pB\%.. (press h for help or q to quit)$--no-init --QUIET --RAW-CONTROL-CHARS --chop-long-lines --ignore-case --search-skip-screen --use-color --color=Sky MAN_PN=quota(1) sh -c col -bx | bat --language man --plain

Note that if you I do which bat after getting the error then try again man quota then I get the proper man pages through bat. It is as if bash forgot where to find bat but once I refresh its memory, it works.

What did you expect to happen instead?

To see the man pages for quota through the eye of bat.

How did you install bat?

cargo install --force bat


bat version and environment

Software version

bat 0.23.0

Operating system

Linux 5.15.0-119-generic

Command-line

bat --diagnostic

Environment variables

SHELL=/bin/bash
PAGER=<not set>
LESS='--no-init --QUIET --RAW-CONTROL-CHARS --chop-long-lines --ignore-case --search-skip-screen --use-color --color=Sky'
LANG=<not set>
LC_ALL=en_CA.UTF-8
BAT_PAGER=<not set>
BAT_CACHE_PATH=<not set>
BAT_CONFIG_PATH=<not set>
BAT_OPTS=<not set>
BAT_STYLE=<not set>
BAT_TABS=<not set>
BAT_THEME=<not set>
XDG_CONFIG_HOME=<not set>
XDG_CACHE_HOME=<not set>
COLORTERM=<not set>
NO_COLOR=<not set>
MANPAGER='sh -c '\''col -bx | bat --language man --plain'\'''

System Config file

Could not read contents of '/etc/bat/config': No such file or directory (os error 2).

Config file

Could not read contents of '$HOME/.config/bat/config': No such file or directory (os error 2).

Custom assets metadata

Could not read contents of '$HOME/.cache/bat/metadata.yaml': No such file or directory (os error 2).

Custom assets

'$HOME/.cache/bat' not found

Compile time information

  • Profile: release
  • Target triple: x86_64-unknown-linux-gnu
  • Family: unix
  • OS: linux
  • Architecture: x86_64
  • Pointer width: 64
  • Endian: little
  • CPU features: fxsr,sse,sse2
  • Host: x86_64-unknown-linux-gnu

Less version

> less --version
less 590 (GNU regular expressions)
Copyright (C) 1984-2021  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.
Home page: https://greenwoodsoftware.com/less
@SamuelLarkin SamuelLarkin added the bug Something isn't working label Sep 18, 2024
@keith-hall
Copy link
Collaborator

Are you able to use bat outside the context of a MANPAGER or do you get the same permission denied error initially?
Maybe worth putting the full path to bat in your MANPAGER instead of just the executable name to see if it solves the issue

@SamuelLarkin
Copy link
Author

It happened again.
man nvidia-smi

sh: 1: bat: Permission denied
man: command exited with status 127: sed -e '/^[[:space:]]*$/{ N; /^[[:space:]]*\n[[:space:]]*$/D; }' | LESS=-ix8RmPm Manual page nvidia-smi(1) ?ltline %lt?L/%L.:byte %bB?s/%s..?e (END):?pB %pB\%.. (press h for help or q to quit)$PM Manual page nvidia-smi(1) ?ltline %lt?L/%L.:byte %bB?s/%s..?e (END):?pB %pB\%.. (press h for help or q to quit)$--no-init --QUIET --RAW-CONTROL-CHARS --chop-long-lines --ignore-case --search-skip-screen --use-color --color=Sky MAN_PN=nvidia-smi(1) sh -c col -bx | bat --language man --plain

I then immediately did bat <A_FILE> after getting the error and got the desired out aka the file's content.
Then without doing which bat, I did man nvidia-smi worked as expected.

I'll try changing export MANPAGER="sh -c 'col -bx | bat --language man --plain'" to export MANPAGER="sh -c 'col -bx | ~/.local/bin/bat --language man --plain'" to see if I get the error.

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

2 participants