Less misbehaves when used for "man" pager...

Chip Salzenberg chip at tct.com
Sun Apr 28 06:03:49 AEST 1991


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 at 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



More information about the Comp.unix.sysv386 mailing list