-_version BSD.2
-_subdir man{[1-9],1x}
-_suffix .0
-_build .[1-9] mandoc %s
-_build .tbl tbl %s | mandoc
-_default /usr/{,pkg/{,gcc*/}}man
-_whatdb /usr/{,pkg/{,gcc*/}}man/whatis.db
-1 man1
-2 man2
-3 man3
-4 man4
-5 man5
-6 man6
-7 man7
-8 man8
-9 man9
+# $NetBSD: man.conf,v 1.31 2012/10/06 15:33:59 wiz Exp $
+
+# Sheer, raging paranoia...
+_version BSD.2
+
+# The whatis/apropos database.
+_mandb /var/db/man.db
+
+# Subdirectories for paths ending in '/', IN SEARCH ORDER.
+_subdir cat1 man1 cat8 man8 cat6 man6 cat2 man2 cat3 man3 cat4 man4 cat5 man5 cat7 man7 man3f cat9 man9 catn mann catl manl
+
+# Files typed by suffix and their commands.
+# Note the order, .Z must come after .[1-9].Z, or it will match first.
+_suffix .0
+_build .0.Z /usr/bin/zcat %s
+_build .0.bz2 /usr/bin/bzcat %s
+_build .0.gz /usr/bin/zcat %s
+_build .0.xz /usr/bin/xzcat %s
+_build .[1-9ln] /usr/bin/mandoc %s
+_build .[1-9ln].Z /usr/bin/zcat %s | /usr/bin/mandoc
+_build .[1-9ln].bz2 /usr/bin/bzcat %s | /usr/bin/mandoc
+_build .[1-9ln].gz /usr/bin/zcat %s | /usr/bin/mandoc
+_build .[1-9ln].xz /usr/bin/xzcat %s | /usr/bin/mandoc
+_build .tbl /usr/bin/mandoc %s
+_build .tbl.Z /usr/bin/zcat %s | /usr/bin/mandoc
+_build .tbl.bz2 /usr/bin/bzcat %s | /usr/bin/mandoc
+_build .tbl.gz /usr/bin/zcat %s | /usr/bin/mandoc
+_build .tbl.xz /usr/bin/xzcat %s | /usr/bin/mandoc
+
+_build .me /usr/bin/nroff -msafer -me %s 2>/dev/null | cat -s
+
+_crunch .Z /usr/bin/zcat > %s
+_crunch .bz /usr/bin/bzcat > %s
+_crunch .gz /usr/bin/zcat > %s
+_crunch .xz /usr/bin/xzcat > %s
+
+# Sections and their directories.
+# All paths ending in '/' are the equivalent of entries specifying that
+# directory with all of the subdirectories listed for the keyword _subdir.
+
+# default
+# MINIX: Add /usr/man ...
+_default /usr/{,share,X11R7,X11R6,pkg,local}/man/
+
+# Other sections that represent complete man subdirectories.
+X11R7 /usr/X11R7/man/
+X11R6 /usr/X11R6/man/
+packages /usr/pkg/man/
+local /usr/local/man/
+
+# Specific section/directory combinations.
+1 {cat,man}1
+2 {cat,man}2
+3 {cat,man}3
+3F {cat,man}3f
+3f {cat,man}3f
+4 {cat,man}4
+5 {cat,man}5
+6 {cat,man}6
+7 {cat,man}7
+8 {cat,man}8
+9 {cat,man}9
+l {cat,man}l
+n {cat,man}n
+
+# machine classes per machine
+_i386 x86
+_amd64 x86
+_sparc64 sparc
2012/10/17 12:00:00,usr.bin/make
2012/10/17 12:00:00,usr.bin/Makefile
2012/10/17 12:00:00,usr.bin/Makefile.inc
-2010/07/07 21:24:34,usr.bin/man
+2012/10/17 12:00:00,usr.bin/man
2012/10/17 12:00:00,usr.bin/menuc
2013/10/25 12:00:00,usr.bin/mesg
2010/10/15 05:46:48,usr.bin/mkdep
-.\" $NetBSD: man.1,v 1.21 2009/10/07 08:30:31 cegger Exp $
+.\" $NetBSD: man.1,v 1.24 2011/10/07 10:52:31 mbalmer Exp $
.\"
.\" Copyright (c) 1989, 1990, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" @(#)man.1 8.2 (Berkeley) 1/2/94
.\"
-.Dd October 6, 2009
+.Dd October 7, 2011
.Dt MAN 1
.Os
.Sh NAME
.Oc
.Ar name Ar ...
.Nm
-.Op Fl k
+.Fl k
.Op Fl C Ar file
.Op Fl M Ar path
.Op Fl m Ar path
.Ar keyword Ar ...
+.Nm
+.Fl p
.Sh DESCRIPTION
The
.Nm
line in the
.Nm
configuration file.
+.It Fl p
+Print the search path for the manual pages.
.It Fl s
Restrict the directories that
.Nm
.Bl -hang -width /etc/man.conf -compact
.It Pa /etc/man.conf
default man configuration file.
-.It Pa /usr/{share,X11R6,pkg,local}/man/whatis.db
+.It Pa /usr/{share,X11R7,pkg,local}/man/whatis.db
standard whatis/apropos database search path,
set in
.Pa /etc/man.conf .
-/* $NetBSD: man.c,v 1.41 2010/07/07 21:24:34 christos Exp $ */
+/* $NetBSD: man.c,v 1.44 2012/01/03 17:49:57 joerg Exp $ */
/*
* Copyright (c) 1987, 1993, 1994, 1995
#if 0
static char sccsid[] = "@(#)man.c 8.17 (Berkeley) 1/31/95";
#else
-__RCSID("$NetBSD: man.c,v 1.41 2010/07/07 21:24:34 christos Exp $");
+__RCSID("$NetBSD: man.c,v 1.44 2012/01/03 17:49:57 joerg Exp $");
#endif
#endif /* not lint */
#include <sys/param.h>
#include <sys/queue.h>
+#include <sys/stat.h>
#include <sys/utsname.h>
#include <ctype.h>
char *pathsearch; /* -S: path of man must contain this string */
char *sectionname; /* -s: limit search to a given man section */
int where; /* -w: just show paths of all matching files */
-
+ int getpath; /* -p: print the path of directories containing man pages */
+
/* important tags from the config file */
TAG *defaultpath; /* _default: default MANPATH */
TAG *subdirs; /* _subdir: default subdir search list */
static void usage(void) __attribute__((__noreturn__));
static void addpath(struct manstate *, const char *, size_t, const char *);
static const char *getclass(const char *);
+static void printmanpath(struct manstate *);
/*
* main function
/*
* parse command line...
*/
- while ((ch = getopt(argc, argv, "-aC:cfhkM:m:P:s:S:w")) != -1)
+ while ((ch = getopt(argc, argv, "-aC:cfhkM:m:P:ps:S:w")) != -1)
switch (ch) {
case 'a':
m.all = 1;
case 'P': /* -P for backward compatibility */
m.manpath = strdup(optarg);
break;
+ case 'p':
+ m.getpath = 1;
+ break;
/*
* The -f and -k options are backward compatible,
* undocumented ways of calling whatis(1) and apropos(1).
argc -= optind;
argv += optind;
- if (!argc)
+ if (!m.getpath && !argc)
usage();
/*
}
+ if (m.getpath)
+ printmanpath(&m);
+
/*
* now m.mymanpath is complete!
*/
(void)fprintf(stderr,
"Usage: %s -k [-C cfg] [-M path] [-m path] keyword ...\n",
getprogname());
+ (void)fprintf(stderr, "Usage: %s -p\n", getprogname());
exit(EXIT_FAILURE);
}
+
+/*
+ * printmanpath --
+ * Prints a list of directories containing man pages.
+ */
+static void
+printmanpath(struct manstate *m)
+{
+ ENTRY *esubd;
+ char *defaultpath = NULL; /* _default tag value from man.conf. */
+ char *buf; /* for storing temporary values */
+ char **ap;
+ glob_t pg;
+ struct stat sb;
+ TAG *path = m->defaultpath;
+ TAG *subdirs = m->subdirs;
+
+ /* the tail queue is empty if no _default tag is defined in * man.conf */
+ if (TAILQ_EMPTY(&path->entrylist))
+ errx(EXIT_FAILURE, "Empty manpath");
+
+ defaultpath = TAILQ_LAST(&path->entrylist, tqh)->s;
+
+ if (glob(defaultpath, GLOB_BRACE | GLOB_NOSORT, NULL, &pg) != 0)
+ err(EXIT_FAILURE, "glob failed");
+
+ if (pg.gl_matchc == 0) {
+ warnx("Default path in %s doesn't exist", _PATH_MANCONF);
+ globfree(&pg);
+ return;
+ }
+
+ TAILQ_FOREACH(esubd, &subdirs->entrylist, q) {
+ /* Drop cat page directory, only sources are relevant. */
+ if (strncmp(esubd->s, "man", 3))
+ continue;
+
+ for (ap = pg.gl_pathv; *ap != NULL; ++ap) {
+ if (asprintf(&buf, "%s%s", *ap, esubd->s) == -1)
+ err(EXIT_FAILURE, "memory allocation error");
+ /* Skip non-directories. */
+ if (stat(buf, &sb) == 0 && S_ISDIR(sb.st_mode))
+ printf("%s\n", buf);
+
+ free(buf);
+ }
+ }
+ globfree(&pg);
+}
-.\" $NetBSD: man.conf.5,v 1.20 2007/02/10 19:27:39 reed Exp $
+.\" $NetBSD: man.conf.5,v 1.22 2012/04/29 03:46:43 christos Exp $
.\"
.\" Copyright (c) 1989, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" @(#)man.conf.5 8.5 (Berkeley) 1/2/94
.\"
-.Dd April 10, 2006
+.Dd April 28, 2012
.Dt MAN.CONF 5
.Os
.Sh NAME
The rest of the _build line is a shell command line whose standard
output is a formatted manual page that can be directly displayed to
the user.
-Any occurrences of the string
+There should be exactly one occurrence of the string
.Dq %s
-in the shell command line will
+in the shell command line, and it will
be replaced by the name of the file which is being formatted.
.It _crunch
used by
which indicates what kind of compression were used to compress the man page.
The rest of the line must be a shell command line, used to compress the
formatted pages.
+There should be exactly one occurrence of the string
+.Dq %s
+in the shell command line, and it will
+be replaced by the name of the output file.
.It _default
contains the system-wide default man path used to search for man pages.
.It _subdir
to escape a shell globbing character,
precede it with a backslash
.Pq Dq \e .
+.It _\*[Lt]machine\*[Gt]
+The defines additional paths to be searched for the particular
+.Dv machine
+whose literal value is taken from
+.Xr uname 1
+.Fl m .
+For example on an
+.Dv amd64 ,
+.Dv _amd64
+is used.
.El
.Pp
Section configuration lines in
_suffix .0
_build .[1-9] nroff -man %s
_build .tbl tbl %s | nroff -man
+_i386 x86
_default /usr/share/man/
sect3 /usr/share/man/{old/,}cat3
.Ed