[comp.unix.sysv386] Less misbehaves when used for "man" pager...

fields-doug@CS.YALE.EDU (Doug Fields) (04/24/91)

I have been running less (can't say which version but it's recent. 1.90
perhaps?) sicne i've been running SCO Xenix and moved to SCO Unix. When
I edit the /etc/default/man so that it uses less for the pager instead
of pg, and you try to read a un-formatted man page (I installed the TPS
from Xenix on my Unix), less will spew out a ton of warnings about things
the terminal can't do, such as scroll backwards, etc. This has happened from
both SCO products, 3.2.2 Unix and 2.3.3 Xenix. Is the TERM environment variable
somehow misplaced or something?

It was a bigger problem under Xenix because all man pages were unformatted.
With Unix they're formatted already (because SCO is too lazy to include
an nroff). But whenever I get man pages on any other man entry I have,
guess what... It gives me those errors.

Thanks for any help.

Doug
-- 
Doug Fields -POB 1789 Yale Station, New Haven, CT 06520- (FAX) +1 203 661-2996
Internet: fields-doug@cs.yale.edu <-- Best to reach me. Voice: +1 203 436-0184
uucp: ...uunet!sir-alan!admiral!doug --------------------- Thank you Sir-Alan!
BBS: (T2500) +1 203 661-2873, (HST/V.32) -1279, (V.32) -0450, (v29/MNP6) -2967

curt@cynic.wimsey.bc.ca (Curt Sampson) (04/24/91)

In article <30370@cs.yale.edu>
  fields-doug@CS.YALE.EDU (Doug Fields) writes:

> I edit the /etc/default/man so that it uses less for the pager instead
> of pg, and you try to read a un-formatted man page (I installed the TPS
> from Xenix on my Unix), less will spew out a ton of warnings about things
> the terminal can't do, such as scroll backwards, etc.

This is not a problem with less.  The SCO 'man' command is rather
broken.  If you substitute more for less, you will notice that more
will not do the underlining that it normally does if man has to
run the formatter on the page.

I've been meaning to write a shell script to replace man for quite a
while, but haven't gotten around to it.  There's probably one out
there already, anyway.  Anybody care to give me a pointer to it?  (If
there isn't, I'll probably get on it sooner.)

cjs
-- 
Curt Sampson            | "It is actually a feature of UUCP that the map of
curt@cynic.uucp         | all systems in the network is not known anywhere."
curt@cynic.wimsey.bc.ca |    --Berkeley Mail Reference Manual (Kurt Schoens)

vic@grep.co.uk (Victor Gavin) (04/25/91)

In article <30370@cs.yale.edu> fields-doug@CS.YALE.EDU (Doug Fields) writes:
>I have been running less (can't say which version but it's recent. 1.90
>perhaps?) sicne i've been running SCO Xenix and moved to SCO Unix. When
>I edit the /etc/default/man so that it uses less for the pager instead
>of pg, and you try to read a un-formatted man page (I installed the TPS
>from Xenix on my Unix), less will spew out a ton of warnings about things
>the terminal can't do, such as scroll backwards, etc. This has happened from
>both SCO products, 3.2.2 Unix and 2.3.3 Xenix. Is the TERM environment variable
>somehow misplaced or something?

If you look in the /etc/default/man file you'll see that there is a
variable called TERM which is set to (normally) lp. The man command
reads this and reset your true TERM to this value. This is why less
complains about not being able to understand your terminal. You can
verify this by running a subshell from less and echoing TERM.

The reason the SCO reset TERM from within /etc/default/man is to allow
for the command /usr/man/bin/nr which is invoked to format manual
pages which aren't in preformated form. TERM is then passed to the
nroff command (which isn't supplied with SCO !).

To fix this I just changed all occurrences of TERM in /etc/default/man
and /usr/man/bin/nr to MTERM and edited the binary /usr/bin/man and
replaced all occurrences of TERM=\0\0 with MTERM=\0. I was able to do
this because the strings are 0 padded to the nearest 4byte boundary,
so that to add a new letter, I had to remove one of the 0's. If there
hadn't been a spare \0 to remove, then renaming the variable would
have been sufficient (eg TERM -> MRET).

Remember to save your original man command.


		vic

PS Since we've got a network of machines here, I have a shell script
called nroff that calls nroff on another machine. Works great :-)
--
Victor Gavin <vic@grep.co.uk||..!ukc!grep!vic||..!ukc!vision!grep!vic>

slootman@dri.nl (Paul Slootman) (04/26/91)

In article <30370@cs.yale.edu> fields-doug@CS.YALE.EDU (Doug Fields) writes:
>I have been running less (can't say which version but it's recent. 1.90
>perhaps?) sicne i've been running SCO Xenix and moved to SCO Unix. When
>I edit the /etc/default/man so that it uses less for the pager instead
>of pg, and you try to read a un-formatted man page (I installed the TPS
>from Xenix on my Unix), less will spew out a ton of warnings about things
>the terminal can't do, such as scroll backwards, etc. This has happened from
>both SCO products, 3.2.2 Unix and 2.3.3 Xenix. Is the TERM environment variable
>somehow misplaced or something?

I've done the same; however, I've noticed that when I encounter an
unformatted manpage while logged in as root, there is *NO* problem.
Logged in as a regular user (running csh), I get the problems described
above.

BTW: If you're looking at a manpage which is being formatted at that
moment, *DON'T* hit 'q' until you're at the end; this could cause you
to end up with a manpage that is not complete. This is especially the
case if the manpage is long (csh comes to mind). Or have I done
something wrong somewhere?
-- 
 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
: slootman@dri.nl           : You are wise, witty and wonderful, but you      :
: ...!hp4nl!dri500!slootman : spend too much time reading this sort of trash. :
 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

mju@mudos.ann-arbor.mi.us (Marc Unangst) (04/26/91)

fields-doug@CS.YALE.EDU (Doug Fields) writes:
> of pg, and you try to read a un-formatted man page (I installed the TPS
> from Xenix on my Unix), less will spew out a ton of warnings about things
> the terminal can't do, such as scroll backwards, etc. This has happened from
> both SCO products, 3.2.2 Unix and 2.3.3 Xenix. Is the TERM environment variab
> somehow misplaced or something?

Sort of.  If you look closely at how man does things, you'll notice
that when it has to format a man page, it hands all the commands it
uses "TERM=dumb" and then filters the output through "col -b".  This
is, I suppose, to keep the output suitable for display on a video
terminal.  Unfortunately, this means that "less" thinks your terminal
is dumb, which causes it to complain.  (To supress this complaint, use
"less -d", assuming your version of less supports it.)  Unfortunately,
it also means that if man formats a man page, the resultant formatted
copy will not have underlining or boldfacing in it, so "less" won't
display them.  (Neither will "more", for that matter.)

The solution, under Xenix, is to do something like this from /usr/man:

for i in man.*
do	cd $i
	c=`echo $i | sed 's/man/cat/'`
	for j in *
	do	if [ ! -f ../$c/$j ]
		then	nroff -man $j >../$c/$j
			pack ../$c/$j
		fi
	done
	cd ..
done

This will step through all of your man.* directories, format any man
pages that haven't yet been formatted, and then run "pack" on them so
they take up less space.  (You really should use "compress" instead,
but SCO man(1) doesn't understand .Z by default, and also doesn't
include compress with Xenix.  If you have Xenix, where man(1) is a
shell script, you can add .Z support, and use compress if you have
it.  If you have Unix, you're SOL unless you want to rip out SCO's
version of man and replace it with something of your own invention.)
If you want to format all the man pages, not just the ones that
haven't yet been formatted, simply take out the if statement that
checks for the formatted man page.

--
Marc Unangst               |
mju@mudos.ann-arbor.mi.us  | "Bus error: passengers dumped"
...!hela!mudos!mju         | 

chip@tct.com (Chip Salzenberg) (04/28/91)

As has already been described by other posters, the SCO "man" command
clobbers the TERM environment variable when running the pager of
choice.

I fixed it locally by (1) creating /u/local/bin/man which is in the
search path first, which sets the environment variable REALTERM to the
value of TERM before running /usr/bin/man, (2) in /etc/default/man
setting PAGER=/usr/man/bin/less-term, and (3) in the less-term script,
setting TERM from REALTERM.  As a bonus, if REALTERM is not set, it
checks the terminal type in /etc/ttytype.

Here is the less-term script.  Shar and enjoy.

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  less-term
# Wrapped by chip@count on Sat Apr 27 16:02:42 1991
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'less-term' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'less-term'\"
else
echo shar: Extracting \"'less-term'\" \(459 characters\)
sed "s/^X//" >'less-term' <<'END_OF_FILE'
X: less-term
X# "man" pager to get around the nroff TERM=lp hack.
X# Also snarf up all input before displaying,
X# to avoid partially-formatted man pages.
X
Xcase "$REALTERM" in
X"")
X	tty=`tty 0<&2 | sed 's#/dev/##'` || exit 1
X	term=`awk '$2 == "'"$tty"'" { print $1; exit }' /etc/ttytype` || exit 1
X	TERM=$term ; export TERM
X	;;
X*)
X	TERM="$REALTERM" ; export TERM
X	;;
Xesac
X
XT=/tmp/man.$$
Xtrap 'rm -f $T' 0
Xtrap 'exit 1' 1 2 3 13 15
X
Xcat >$T
X/u/local/bin/less -e $T
END_OF_FILE
if test 459 -ne `wc -c <'less-term'`; then
    echo shar: \"'less-term'\" unpacked with wrong size!
fi
chmod +x 'less-term'
# end of 'less-term'
fi
echo shar: End of shell archive.
exit 0

mike@bria.UUCP (Michael Stefanik) (04/28/91)

In an article, mju@mudos.ann-arbor.mi.us (Marc Unangst) writes:
|[...]
|You really should use "compress" instead, but SCO man(1) doesn't
|understand .Z by default, and also doesn't include compress with
|Xenix. 
|[...]

Actually, with 2.3x the compress tool *is* distributed with the
XENIX base operating system.

-- 
Michael Stefanik, MGI Inc, Los Angeles | Opinions stated are never realistic
Title of the week: Systems Engineer    | UUCP: ...!uunet!bria!mike
-------------------------------------------------------------------------------
If MS-DOS didn't exist, who would UNIX programmers have to make fun of?

jpr@jpradley.jpr.com (Jean-Pierre Radley) (04/30/91)

In article <1991Apr24.073552.26561@cynic.wimsey.bc.ca> curt@cynic.wimsey.bc.ca (Curt Sampson) writes:
>In article <30370@cs.yale.edu>
>  fields-doug@CS.YALE.EDU (Doug Fields) writes:
>
>> I edit the /etc/default/man so that it uses less for the pager instead
>> of pg, and you try to read a un-formatted man page (I installed the TPS
>> from Xenix on my Unix), less will spew out a ton of warnings about things
>> the terminal can't do, such as scroll backwards, etc.
>
>This is not a problem with less.  The SCO 'man' command is rather
>broken.  If you substitute more for less, you will notice that more
>will not do the underlining that it normally does if man has to
>run the formatter on the page.
>
>I've been meaning to write a shell script to replace man for quite a
>while, but haven't gotten around to it.  There's probably one out
>there already, anyway.  Anybody care to give me a pointer to it?  (If
>there isn't, I'll probably get on it sooner.)

It's been done. Chip Rosenthal posted 'yaman', or 'myman', a couple of years
ago.
It isn't too long, so I can email to anyone who wishes.

Jean-Pierre Radley   Unix in NYC   jpr@jpr.com   jpradley!jpr   CIS: 72160,1341