How does man know?
gregg.g.wonderly
gregg at cbnewsc.ATT.COM
Sat Sep 30 07:43:29 AEST 1989
>From article <11182 at smoke.BRL.MIL>, by gwyn at smoke.BRL.MIL (Doug Gwyn):
> In article <592 at crdos1.crd.ge.COM> davidsen at crdos1.UUCP (bill davidsen) writes:
>> And guess what? It *is* convenient to have it work that way.
>
> No, it isn't. One can easily add pagination in those cases where it
> is desired, but it's much more difficult to defeat wired-in pagination
> in those cases where it isn't desired.
There are many arguments both ways. In a newer version of the man(1) program
that I posted to comp.sources years ago, I decided to adopt the following
strategy. It provides alternatives for all the choices.
if (isatty (1)) {
If $MANPAGER is defined {
if ($MANPAGER == "")
pager = "cat";
else
pager = $MANPAGER
} else if $PAGER is defined
pager = $PAGER
else
pager = "pg";
}
I admit that all of the contortions and exceptions bend the mind a bit.
The obvious question is why choose pg(1) by default over cat(1). Especially
since a user without PAGER set is probably too naive to know how to use
pg(1) anyway. IMHO that a pager should always be available. Naive users
probably also don't know how to use noscroll or ^S/^Q either.
I prefer to have the pager on by default because I almost always want
to use it. I don't know of anything other than the current pagers, such
as pg(1) and less(1), that accept a file on standard input and then
allow you to page up and down searching (as the original article
discussed the need for).
> Consider "man whatever > /dev/tty_printer". Why should that try to
> paginate?
That is precisely where isatty(3) comes in handy. It should not and
because you can not possibly program in all the possibilities, the
easiest (but not the best) solution is to cover the common cases and
let the user who knows more about their environment write
frontend and/or backend programs/scripts to take care of that stuff.
The best example is printing manual pages. My manual program does
NOT provide a printing feature. Instead it provides the capability
to return the path to the manual pages so that nroff/troff/whatever
can be used to format it.
--
-----
gregg.g.wonderly at att.com (AT&T bell laboratories)
More information about the Comp.unix.questions
mailing list