aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2020-07-20 16:57:29 +0000
committerIngo Schwarze <schwarze@openbsd.org>2020-07-20 16:57:29 +0000
commiteb396f5b0bb17fecfc3db0045d2979fa42d4478d (patch)
tree3b8fb3cbf1050568658bfa9406b2b9eb514f1c0d
parentd9eddf28f1aa31476f2335c1e6fc7002b64ea830 (diff)
downloadmandoc-eb396f5b0bb17fecfc3db0045d2979fa42d4478d.tar.gz
mandoc-eb396f5b0bb17fecfc3db0045d2979fa42d4478d.tar.zst
mandoc-eb396f5b0bb17fecfc3db0045d2979fa42d4478d.zip
Switch the default pager from "more -s" to "less".
POSIX explicitly allows using a different default pager if that is documented. Nowadays, the pager provided in most operating systems is less(1). Our man(1) implementation uses less(1) features that traditional more(1) did not provide, in particular tagging. Besides, as noted by deraadt@, the user interface of less(1) is slightly more refined and preferable over the user inferface of more(1). This switch was originally suggested by Ian Ropers. In ./configure, test whether less(1) is available. If not, fall back to more(1). In ./configure.local, support overriding the automatic test by setting BINM_PAGER. As explained by jmc@ and deraadt@, the -s flag was added a very long time ago when an antique version of groff(1) had an annoying bug in terminal output that would randomly display blank lines in the middle of pages. Clearly, -s has no longer been needed for many years, so drop it from the default pager invocation. OK deraadt@ jmc@ martijn@ job@ on the OpenBSD version of this patch.
-rw-r--r--apropos.111
-rwxr-xr-xconfigure32
-rw-r--r--configure.local.example10
-rw-r--r--main.c4
-rw-r--r--man.111
-rw-r--r--mandoc.111
6 files changed, 51 insertions, 28 deletions
diff --git a/apropos.1 b/apropos.1
index 01d2a6bf..c85de86d 100644
--- a/apropos.1
+++ b/apropos.1
@@ -1,4 +1,4 @@
-.\" $Id: apropos.1,v 1.49 2018/11/22 12:33:52 schwarze Exp $
+.\" $Id: apropos.1,v 1.50 2020/07/20 16:57:29 schwarze Exp $
.\"
.\" Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
.\" Copyright (c) 2011,2012,2014,2017,2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -15,7 +15,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: November 22 2018 $
+.Dd $Mdocdate: July 20 2020 $
.Dt APROPOS 1
.Os
.Sh NAME
@@ -73,7 +73,7 @@ would.
If the standard output is a terminal device and
.Fl c
is not specified, use
-.Xr more 1
+.Xr less 1
to paginate them.
In
.Fl a
@@ -340,7 +340,7 @@ types appearing in function arguments in the SYNOPSIS
Any non-empty value of the environment variable
.Ev MANPAGER
is used instead of the standard pagination program,
-.Xr more 1 ;
+.Xr less 1 ;
see
.Xr man 1
for details.
@@ -363,8 +363,7 @@ Specifies the pagination program to use when
.Ev MANPAGER
is not defined.
If neither PAGER nor MANPAGER is defined,
-.Xr more 1
-.Fl s
+.Xr less 1
is used.
Only used if
.Fl a
diff --git a/configure b/configure
index 1b1a5755..377d49c5 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# $Id: configure,v 1.76 2020/06/22 20:00:38 schwarze Exp $
+# $Id: configure,v 1.77 2020/07/20 16:57:30 schwarze Exp $
#
# Copyright (c) 2014-2020 Ingo Schwarze <schwarze@openbsd.org>
#
@@ -119,6 +119,7 @@ BINM_MAKEWHATIS="makewhatis"
BINM_MAN="man"
BINM_SOELIM="soelim"
BINM_WHATIS="whatis"
+BINM_PAGER=
MANM_MAN="man"
MANM_MANCONF="man.conf"
MANM_MDOC="mdoc"
@@ -343,18 +344,34 @@ else
runtest fts FTS || true
fi
+# --- pager ---
+manual=
+if [ -n "${BINM_PAGER}" ]; then
+ manual=" (manual)"
+elif less test-noop.c 1>/dev/null 2>&3; then
+ BINM_PAGER=less
+ echo "tested less: yes" 1>&2
+ echo "tested less: yes" 1>&3
+else
+ BINM_PAGER=more
+ echo "tested less: no" 1>&2
+ echo "tested less: no" 1>&3
+fi
+echo "selected BINM_PAGER=${BINM_PAGER}${manual}" 1>&2
+echo "selected BINM_PAGER=${BINM_PAGER}${manual}" 1>&3
+
# --- tagging support in the pager ---
-if ismanual "less -T" LESS_T ${HAVE_LESS_T}; then
+if ismanual "${BINM_PAGER} -T" LESS_T ${HAVE_LESS_T}; then
:
-elif less -ET /dev/null test-noop.c 1>/dev/null 2>&3; then
+elif ${BINM_PAGER} -T /dev/null test-noop.c 1>/dev/null 2>&3; then
HAVE_LESS_T=1
- echo "tested less -T: yes" 1>&2
- echo "tested less -T: yes" 1>&3
+ echo "tested ${BINM_PAGER} -T: yes" 1>&2
+ echo "tested ${BINM_PAGER} -T: yes" 1>&3
echo 1>&3
else
HAVE_LESS_T=0
- echo "tested less -T: no" 1>&2
- echo "tested less -T: no" 1>&3
+ echo "tested ${BINM_PAGER} -T: no" 1>&2
+ echo "tested ${BINM_PAGER} -T: no" 1>&3
echo 1>&3
fi
@@ -493,6 +510,7 @@ cat << __HEREDOC__
#define BINM_MAN "${BINM_MAN}"
#define BINM_SOELIM "${BINM_SOELIM}"
#define BINM_WHATIS "${BINM_WHATIS}"
+#define BINM_PAGER "${BINM_PAGER}"
__HEREDOC__
diff --git a/configure.local.example b/configure.local.example
index 63f16865..b717e477 100644
--- a/configure.local.example
+++ b/configure.local.example
@@ -1,4 +1,4 @@
-# $Id: configure.local.example,v 1.38 2020/06/22 20:00:38 schwarze Exp $
+# $Id: configure.local.example,v 1.39 2020/07/20 16:57:30 schwarze Exp $
#
# Copyright (c) 2014-2019 Ingo Schwarze <schwarze@openbsd.org>
#
@@ -151,6 +151,14 @@ BINM_WHATIS=mwhatis # default is "whatis"
BINM_MAKEWHATIS=mandocdb # default is "makewhatis"
BINM_SOELIM=msoelim # default is "soelim"
+# If less(1) is available, it is used as the default manual pager.
+# Otherwise, more(1) is used: its existence is required by POSIX.
+# It is possible to force using a different default pager, either
+# by giving the name of a program found in the PATH, or by giving
+# an absolute path.
+
+BINM_PAGER=pg # default is "less" or "more"
+
# Some distributions do not want hardlinks
# between installed binary programs.
# Set the following variable to use symbolic links instead.
diff --git a/main.c b/main.c
index cafbeb9f..c32caee7 100644
--- a/main.c
+++ b/main.c
@@ -1,4 +1,4 @@
-/* $Id: main.c,v 1.350 2020/06/15 17:25:42 schwarze Exp $ */
+/* $Id: main.c,v 1.351 2020/07/20 16:57:30 schwarze Exp $ */
/*
* Copyright (c) 2010-2012, 2014-2020 Ingo Schwarze <schwarze@openbsd.org>
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
@@ -1218,7 +1218,7 @@ spawn_pager(struct outstate *outst, char *tag_target)
if (pager == NULL || *pager == '\0')
pager = getenv("PAGER");
if (pager == NULL || *pager == '\0')
- pager = "more -s";
+ pager = BINM_PAGER;
cp = mandoc_strdup(pager);
/*
diff --git a/man.1 b/man.1
index fe8f1974..d3a54c6a 100644
--- a/man.1
+++ b/man.1
@@ -1,4 +1,4 @@
-.\" $Id: man.1,v 1.39 2020/06/17 19:42:32 schwarze Exp $
+.\" $Id: man.1,v 1.40 2020/07/20 16:57:30 schwarze Exp $
.\"
.\" Copyright (c) 1989, 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -31,7 +31,7 @@
.\"
.\" @(#)man.1 8.2 (Berkeley) 1/2/94
.\"
-.Dd $Mdocdate: June 17 2020 $
+.Dd $Mdocdate: July 20 2020 $
.Dt MAN 1
.Os
.Sh NAME
@@ -74,7 +74,7 @@ See
for a description of the contents of this file.
.It Fl c
Copy the manual page to the standard output instead of using
-.Xr more 1
+.Xr less 1
to paginate it.
This is done by default if the standard output is not a terminal device.
.Pp
@@ -275,7 +275,7 @@ is case insensitive.
Any non-empty value of the environment variable
.Ev MANPAGER
is used instead of the standard pagination program,
-.Xr more 1 .
+.Xr less 1 .
If
.Xr less 1
is used, the interactive
@@ -329,8 +329,7 @@ Specifies the pagination program to use when
.Ev MANPAGER
is not defined.
If neither PAGER nor MANPAGER is defined,
-.Xr more 1
-.Fl s
+.Xr less 1
is used.
.El
.Sh FILES
diff --git a/mandoc.1 b/mandoc.1
index d2294080..43f8d469 100644
--- a/mandoc.1
+++ b/mandoc.1
@@ -15,7 +15,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: June 15 2020 $
+.Dd $Mdocdate: July 20 2020 $
.Dt MANDOC 1
.Os
.Sh NAME
@@ -52,13 +52,13 @@ The options are as follows:
If the standard output is a terminal device and
.Fl c
is not specified, use
-.Xr more 1
+.Xr less 1
to paginate the output, just like
.Xr man 1
would.
.It Fl c
Copy the formatted manual pages to the standard output without using
-.Xr more 1
+.Xr less 1
to paginate them.
This is the default.
It can be specified to override
@@ -650,7 +650,7 @@ It never affects the interpretation of input files.
Any non-empty value of the environment variable
.Ev MANPAGER
is used instead of the standard pagination program,
-.Xr more 1 ;
+.Xr less 1 ;
see
.Xr man 1
for details.
@@ -664,8 +664,7 @@ Specifies the pagination program to use when
.Ev MANPAGER
is not defined.
If neither PAGER nor MANPAGER is defined,
-.Xr more 1
-.Fl s
+.Xr less 1
is used.
Only used if
.Fl a