summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2020-02-10 13:49:05 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2020-02-10 13:49:05 +0000
commitb6cdabdcbc454218bd131a4b3b93508e95e9e200 (patch)
tree094ceafa37e8eaa39dd370d54aca2613a519113b /usr.bin/mandoc
parentf5d971dfbe509511cd4cf2ee4a196da93e8ee401 (diff)
For compatibility with the man(1) implementations of the man-1.6
and man-db packages, print the manpath if the -w option is given without a following name argument. This quirk has been in man-1.6 since at least man-1.5e (1998) and in man-db since 2012. Using this feature in portable software is a dubious idea because the internal organization of manual page directories varies in about a dozen respects among operating systems, so even if you get the answer, there is no portable way to use it for looking up anything inside. However, Matej Cepl <mcepl at suse dot cz> made me aware that some software, for example the manual viewing functionality in the newest editors/neovim code, unwisely relies on this feature anyway. No objections were raised when this patch was shown on tech@.
Diffstat (limited to 'usr.bin/mandoc')
-rw-r--r--usr.bin/mandoc/main.c18
-rw-r--r--usr.bin/mandoc/man.19
2 files changed, 21 insertions, 6 deletions
diff --git a/usr.bin/mandoc/main.c b/usr.bin/mandoc/main.c
index bcf541409d1..694dc415e6d 100644
--- a/usr.bin/mandoc/main.c
+++ b/usr.bin/mandoc/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.245 2020/02/06 19:41:34 schwarze Exp $ */
+/* $OpenBSD: main.c,v 1.246 2020/02/10 13:49:04 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2012, 2014-2020 Ingo Schwarze <schwarze@openbsd.org>
@@ -427,8 +427,20 @@ main(int argc, char *argv[])
/* man(1): Resolve each name individually. */
if (search.argmode == ARG_NAME) {
- if (argc < 1)
- usage(ARG_NAME);
+ if (argc < 1) {
+ if (outmode != OUTMODE_FLN)
+ usage(ARG_NAME);
+ if (conf.manpath.sz == 0) {
+ warnx("The manpath is empty.");
+ mandoc_msg_setrc(MANDOCLEVEL_BADARG);
+ } else {
+ for (i = 0; i + 1 < conf.manpath.sz; i++)
+ printf("%s:", conf.manpath.paths[i]);
+ printf("%s\n", conf.manpath.paths[i]);
+ }
+ manconf_free(&conf);
+ return (int)mandoc_msg_getrc();
+ }
for (res = NULL, ressz = 0; argc > 0; argc--, argv++) {
(void)mansearch(&search, &conf.manpath,
1, argv, &resn, &resnsz);
diff --git a/usr.bin/mandoc/man.1 b/usr.bin/mandoc/man.1
index 72416c5fb02..2d4d33af24b 100644
--- a/usr.bin/mandoc/man.1
+++ b/usr.bin/mandoc/man.1
@@ -1,9 +1,9 @@
-.\" $OpenBSD: man.1,v 1.35 2020/02/08 01:09:58 jsg Exp $
+.\" $OpenBSD: man.1,v 1.36 2020/02/10 13:49:04 schwarze Exp $
.\"
.\" Copyright (c) 1989, 1990, 1993
.\" The Regents of the University of California. All rights reserved.
.\" Copyright (c) 2003, 2007, 2008, 2014 Jason McIntyre <jmc@openbsd.org>
-.\" Copyright (c) 2010, 2011, 2014-2018 Ingo Schwarze <schwarze@openbsd.org>
+.\" Copyright (c) 2010, 2011, 2014-2020 Ingo Schwarze <schwarze@openbsd.org>
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
@@ -31,7 +31,7 @@
.\"
.\" @(#)man.1 8.2 (Berkeley) 1/2/94
.\"
-.Dd $Mdocdate: February 8 2020 $
+.Dd $Mdocdate: February 10 2020 $
.Dt MAN 1
.Os
.Sh NAME
@@ -199,6 +199,9 @@ Kernel internals.
.It Fl w
List the pathnames of all matching manual pages instead of displaying
any of them.
+If no
+.Ar name
+is given, list the directories that would be searched.
.El
.Pp
The options