0

I'm on Mac OS, using GNU Bash and GNU man-db, and I have my MANPAGER set to most.

$ uname
Darwin
$ bash --version
GNU bash, version 5.0.11(1)-release (x86_64-apple-darwin19.0.0)
...
$ man --version
man 2.8.5
$ echo $MANPAGER
most

When I invoke man ls, I see that man does not respect my MANPAGER.

Invoke as <code>man ls</code> does not use <code>most</code>

But when I invoke MANPAGER=most man ls, man uses most to show the manual page.

Invoke as <code>MANPAGER=most man ls</code> uses <code>most</code>

(1) What's going on to keep man from seeing/using my MANPAGE environment variable. I'm at a loss for how to explain this observed behavior.

(2) How can I get man ls to see/use my MANPAGE environment variable, so that I can simply invoke as man ls and don't have to invoke as MANPAGE=most man ls.

Fried Brice
  • 769
  • 7
  • 20
  • 3
    It is possiblming missing the environment variable to be exported: `export MANPAGER=most` – Léa Gris Dec 22 '19 at 00:45
  • That was it. I'm so sorry, everyone <.<; – Fried Brice Dec 22 '19 at 01:10
  • 1
    BTW, in the future, you can detect this using `declare -p MANPAGER`. If it says `declare -- MANPAGER` then it's a regular non-exported shell variable; if it says `set -x MANPAGER`, then it's an environment variable available to all subprocesses the shell runs. – Charles Duffy Dec 22 '19 at 01:20
  • 2
    BTW, in the future, questions about configuring your shell for interactive use are a better fit for our sister site [unix.se]; interactive shell configuration is done by people who aren't developers, whereas Stack Overflow's scope is limited to questions "unique to software development". – Charles Duffy Dec 22 '19 at 01:22

1 Answers1

0

Nothing to do with man specifically, I just wasn't exporting my environment variables in .profile. For whatever reason, I didn't think export was needed for variables defined in .profile. Changing the line MANPAGER=man to export MANPAGER=man fixed my problem.

Fried Brice
  • 769
  • 7
  • 20
  • 1
    If you want to avoid the need to add the explicit `export`, use `set -a` at the top of your `.profile` to turn on auto-export, and `set +a` at the bottom to turn it back off. (You want it off most of the time, because environment space is a limited resource; the same kernel-allocated per-process memory region is also used for command-line arguments, so the more and larger variables you export, the shorter your maximum command line length can be). – Charles Duffy Dec 22 '19 at 01:18