summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--usr.bin/man/man.120
-rwxr-xr-xusr.bin/man/man.sh32
2 files changed, 39 insertions, 13 deletions
diff --git a/usr.bin/man/man.1 b/usr.bin/man/man.1
index 133d536..a9002ec 100644
--- a/usr.bin/man/man.1
+++ b/usr.bin/man/man.1
@@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd June 2, 2011
+.Dd June 3, 2011
.Dt MAN 1
.Os
.Sh NAME
@@ -73,8 +73,12 @@ environment variable.
.It Fl P Ar pager
Use specified pager.
Defaults to
+.Ic "less -sR"
+if color support is enabled, or
.Ic "more -s" .
Overrides the
+.Ev MANPAGER
+environment variable, which in turn overrides the
.Ev PAGER
environment variable.
.It Fl S Ar mansect
@@ -289,9 +293,19 @@ Otherwise, if set to a special value
.Dq Li tty ,
and output is to a terminal,
the pages may be displayed over the whole width of the screen.
-.It Ev PAGER
+.It Ev MANCOLOR
+If set, enables color support.
+.It Ev MANPAGER
Program used to display files.
-If unset,
+.Pp
+If unset, and color support is enabled,
+.Ic "less -sR"
+is used.
+.Pp
+If unset, and color support is disabled, then
+.Ev PAGER
+is used.
+If that has no value either,
.Ic "more -s"
is used.
.El
diff --git a/usr.bin/man/man.sh b/usr.bin/man/man.sh
index 11a9206..98749a6 100755
--- a/usr.bin/man/man.sh
+++ b/usr.bin/man/man.sh
@@ -294,10 +294,10 @@ man_display_page() {
ret=0
else
if [ $debug -gt 0 ]; then
- decho "Command: $cattool $catpage | $PAGER"
+ decho "Command: $cattool $catpage | $MANPAGER"
ret=0
else
- eval "$cattool $catpage | $PAGER"
+ eval "$cattool $catpage | $MANPAGER"
ret=$?
fi
fi
@@ -356,6 +356,10 @@ man_display_page() {
;;
esac
+ if [ -z "$MANCOLOR" ]; then
+ NROFF="$NROFF -P-c"
+ fi
+
if [ -n "${use_width}" ]; then
NROFF="$NROFF -rLL=${use_width}n -rLT=${use_width}n"
fi
@@ -382,7 +386,7 @@ man_display_page() {
if [ -n "$tflag" ]; then
pipeline="$pipeline | $TROFF"
else
- pipeline="$pipeline | $NROFF | $PAGER"
+ pipeline="$pipeline | $NROFF | $MANPAGER"
fi
if [ $debug -gt 0 ]; then
@@ -484,7 +488,7 @@ man_parse_args() {
while getopts 'M:P:S:adfhkm:op:tw' cmd_arg; do
case "${cmd_arg}" in
M) MANPATH=$OPTARG ;;
- P) PAGER=$OPTARG ;;
+ P) MANPAGER=$OPTARG ;;
S) MANSECT=$OPTARG ;;
a) aflag=aflag ;;
d) debug=$(( $debug + 1 )) ;;
@@ -808,7 +812,7 @@ search_whatis() {
bad=${bad#\\n}
if [ -n "$good" ]; then
- echo -e "$good" | $PAGER
+ echo -e "$good" | $MANPAGER
fi
if [ -n "$bad" ]; then
@@ -832,13 +836,21 @@ setup_cattool() {
}
# Usage: setup_pager
-# Correctly sets $PAGER
+# Correctly sets $MANPAGER
setup_pager() {
# Setup pager.
- if [ -z "$PAGER" ]; then
- PAGER="more -s"
+ if [ -z "$MANPAGER" ]; then
+ if [ -n "$MANCOLOR" ]; then
+ MANPAGER="less -sR"
+ else
+ if [ -n "$PAGER" ]; then
+ MANPAGER="$PAGER"
+ else
+ MANPAGER="more -s"
+ fi
+ fi
fi
- decho "Using pager: $PAGER"
+ decho "Using pager: $MANPAGER"
}
# Usage: trim string
@@ -921,7 +933,7 @@ do_whatis() {
# User's PATH setting decides on the groff-suite to pick up.
EQN=eqn
-NROFF='groff -S -P-ch -Wall -mtty-char -man'
+NROFF='groff -S -P-h -Wall -mtty-char -man'
PIC=pic
REFER=refer
TBL=tbl
OpenPOWER on IntegriCloud