Problems with man and less/more

Oliver Fromme olli at lurza.secnetix.de
Tue Nov 14 10:03:32 PST 2006


Philipp Ost wrote:
 > I just stumbled across a oddity when I use the `man'-command piped 
 > through `less' or `more'.
 > 
 > What I do is the following:
 > 1. $ man $some_program
 >         This works without problems.
 > 2. $ man $some_program | less  or: $ man $some_program | more
 >         This works without problems until I type `q' to return to the terminal. 
 > Then the following message appears on the screen[tm] an I get my 
 > shell-prompt:
 > 
 > Error executing formatting or display command.
 > system command exited with status 36096
 > Error executing formatting or display command.
 > system command exited with status 36096
 > No manual entry for less
 > $

The man(1) command doesn't like it at all when its pager
process gets a "broken pipe" signal.  It isn't capable of
handling that situation gracefully.  You can reproduce
the problem without any less(1) involved:

$ export PAGER=cat
$ man csh | head

You will see the same error messages from man(1).

 > For some man-pages (it seems the category doesn't matter), the message 
 > is two lines shorter:
 > 
 > Error executing formatting or display command.
 > system command exited with status 36096
 > No manual entry for X
 > $

It probably depends on the size of the manual page.  For
short pages, the second less(1) instance reaches EOF
before you press "q".

 > There's no difference whether I use `less' or `more'.

They're the same:
465840 -r-xr-xr-x  2 root  wheel  109300 Nov  9 10:43 /usr/bin/less
465840 -r-xr-xr-x  2 root  wheel  109300 Nov  9 10:43 /usr/bin/more

And you can also use head(1), false(1), or "sed 1q", or
any other command that will close its standard input
prematurely (i.e. before it reads everything through EOF).

 > My system is 6.2-PRERELEASE with sources from November 12th:

The problem is pretty old, I can even reproduce it on a
FreeBSD 4.x machine.

Normally there is no need to pipe man(1) output through
less(1) (why would you want to do that?), so there's no
real problem.

Just set $PAGER appropriately.  By the way, the default
(if not set) is "more -s", which is the same as "less -s".
Therefore, piping output from man(1) through less(1)
doesn't really make sense.

Best regards
   Oliver

-- 
Oliver Fromme,  secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing
Dienstleistungen mit Schwerpunkt FreeBSD: http://www.secnetix.de/bsd
Any opinions expressed in this message may be personal to the author
and may not necessarily reflect the opinions of secnetix in any way.

"When your hammer is C++, everything begins to look like a thumb."
        -- Steve Haflich, in comp.lang.c++


More information about the freebsd-stable mailing list