0

When I run man [program], the man page text is output on the terminal (a la cat, without a pager that provides interactivity) instead of opening the man page file in less (so you can scroll, search, etc.):

➜ man git commit
GIT-COMMIT(1)                   Git Manual                  GIT-COMMIT(1)

NAME
       git-commit - Record changes to the repository

SYNOPSIS
[...the rest of the man page]

I've verified that echo $PAGER returns less. Running man -D -P less [program] still outputs to the terminal "like cat does", without providing the ability to scroll or search etc., like less usually does.

Using the debug flag -d, man says "using /usr/bin/less as pager". I'm at a loss for what is happening.

Other useful information:

➜ env | grep LESS       
LESS=-R -M
LESS_TERMCAP_mb=
LESS_TERMCAP_md=
LESS_TERMCAP_me=
LESS_TERMCAP_so=
LESS_TERMCAP_se=
LESS_TERMCAP_us=
LESS_TERMCAP_ue=
➜ echo $TERM     
xterm-256color

I do get an error for only one program. I don't believe it is directly relevant, but see this GH issue for details on that. tl;dr, the error that appears is troff: <standard input>:1: name expected (got '\ '): treated as missing

This is also cross posted to the Manjaro forums here.

Update:

Issue is with zpm-zsh/colorize. I thought doing \man would ignore the function, but \ only ignores aliases. Removing this plugin solves the issue, but I'd like to understand why.

  • 1
    How do you know, especially in the face of the debug output saying otherwise, and the fact that less writes to standard output, that less is not involved here? Use the standard litany. What exactly did the computer do? How exactly is that not as expected? "It used standard output." is not exact. – JdeBP Jan 18 at 17:32
  • @JdeBP Updated. I thought I followed the standard litany, but maybe I don't fully understand stdout and that's where the issue was(?). – James Wright Jan 18 at 17:41
  • 2
    Any idea which amount of lines is reported for the terminal? If somehow one of the involved applications or libraries takes it is in the thousands, you would indeed end up with a result like this. Same thing happens with annoying javascript turning off scrollbars (the whole function), but I suppose now you see the bottom part only as the whole page is output at once (as assumed to fit all on screen). – Mr. Donutz Jan 18 at 18:39
  • 1
    Result of echo "$TERM" and the number of columns and lines reported by stty -a please. – roaima Jan 18 at 18:54
  • 2
    stty please. Not ssty – roaima Jan 18 at 20:25
1

The problem I was running was a namespace matching issue with env.

oh-my-zsh's colored-man-pages uses env when setting up variables:

function colored() {
    env \
        LESS_TERMCAP_mb=$(printf "\e[1;31m") \
        LESS_TERMCAP_md=$(printf "\e[1;31m") \
        LESS_TERMCAP_me=$(printf "\e[0m") \
        LESS_TERMCAP_se=$(printf "\e[0m") \
        LESS_TERMCAP_so=$(printf "\e[1;44;33m") \
        LESS_TERMCAP_ue=$(printf "\e[0m") \
        LESS_TERMCAP_us=$(printf "\e[1;32m") \
        PAGER="${commands[less]:-$PAGER}" \
        _NROFF_U=1 \
        PATH="$HOME/bin:$PATH" \
            "$@"
}

function man() {
    colored man "$@"
}

I also use another plugin, zpm-zsh/colorize which routes env through grv (general colourizer) through as a separate function called env:

function env () {
    =grc --colour=auto env "$@"
}

For whatever reason, grc does something that man doesn't like.

Solution:

1) Don't redefine env through grc using a globally defined function

2) Ensure that env is not an alias/function by using command

function colored() {
    command env \
        LESS_TERMCAP_mb=$(printf "\e[1;31m") \
[....]
}

function man() {
    colored man "$@"
}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.