Allow "-s" to specify a section name, ala the SysV man command.
Unlike the SysV man command, this doesn't allow for the -s argument to be a list.
This commit is contained in:
parent
3201cef754
commit
a097e35162
@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: man.1,v 1.10 2000/05/27 21:33:26 jdolecek Exp $
|
||||
.\" $NetBSD: man.1,v 1.11 2000/06/12 14:53:48 simonb Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1989, 1990, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
@ -47,7 +47,10 @@
|
||||
.Op Fl M Ar path
|
||||
.Op Fl m Ar path
|
||||
.Op Fl S Ar srch
|
||||
.Op Ar section
|
||||
.Oo
|
||||
.Op Fl s
|
||||
.Ar section
|
||||
.Oc
|
||||
.Ar name Ar ...
|
||||
.Nm ""
|
||||
.Op Fl k
|
||||
@ -127,6 +130,16 @@ The subdirectories to be searched, and their search order,
|
||||
is specified by the ``_subdir'' line in the
|
||||
.Nm
|
||||
configuration file.
|
||||
.It Fl s
|
||||
Restrict the directories that
|
||||
.Nm
|
||||
will search. The
|
||||
.Nm
|
||||
configuration file (see
|
||||
.Xr man.conf 5 )
|
||||
specifies the possible
|
||||
.Ar section
|
||||
values that are currently available.
|
||||
.It Fl S
|
||||
Display only man pages that have the specified string in their
|
||||
filenames. This allows the man page search process criteria to be
|
||||
@ -142,25 +155,16 @@ and
|
||||
combination.
|
||||
.El
|
||||
.Pp
|
||||
The optional
|
||||
.Ar section
|
||||
argument restricts the directories that
|
||||
.Nm
|
||||
will search.
|
||||
The
|
||||
.Nm
|
||||
configuration file (see
|
||||
.Xr man.conf 5 )
|
||||
specifies the possible
|
||||
.Ar section
|
||||
values that are currently available.
|
||||
Except when used with the
|
||||
If the
|
||||
.Ql Fl s
|
||||
option is not specified,
|
||||
there is more than one argument,
|
||||
the
|
||||
.Ql Fl k
|
||||
option,
|
||||
if only a single argument is specified or if the first argument is
|
||||
not a valid section,
|
||||
.Nm
|
||||
assumes that the argument is the name of a man page to be displayed.
|
||||
option is not used and the first argument is a valid section, that
|
||||
argument will be used as if specified by the
|
||||
.Ql Fl s
|
||||
option.
|
||||
.Sh ENVIRONMENT
|
||||
.Bl -tag -width MANPATHX
|
||||
.It Ev MACHINE
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: man.c,v 1.24 2000/06/07 18:52:31 thorpej Exp $ */
|
||||
/* $NetBSD: man.c,v 1.25 2000/06/12 14:53:48 simonb Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1987, 1993, 1994, 1995
|
||||
@ -44,7 +44,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 1993, 1994, 1995\n\
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)man.c 8.17 (Berkeley) 1/31/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: man.c,v 1.24 2000/06/07 18:52:31 thorpej Exp $");
|
||||
__RCSID("$NetBSD: man.c,v 1.25 2000/06/12 14:53:48 simonb Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -91,7 +91,7 @@ main(argc, argv)
|
||||
size_t len;
|
||||
int ch, f_cat, f_how, found, abs_section;
|
||||
char **ap, *cmd, *p, *p_add, *p_path;
|
||||
const char *machine, *pager, *conffile, *pathsearch;
|
||||
const char *machine, *pager, *conffile, *pathsearch, *sectionname;
|
||||
char buf[MAXPATHLEN * 2];
|
||||
|
||||
#ifdef __GNUC__
|
||||
@ -99,9 +99,8 @@ main(argc, argv)
|
||||
#endif
|
||||
|
||||
f_cat = f_how = 0;
|
||||
conffile = p_add = p_path = NULL;
|
||||
pathsearch = NULL;
|
||||
while ((ch = getopt(argc, argv, "-aC:cfhkM:m:P:S:w")) != -1)
|
||||
sectionname = pathsearch = conffile = p_add = p_path = NULL;
|
||||
while ((ch = getopt(argc, argv, "-aC:cfhkM:m:P:s:S:w")) != -1)
|
||||
switch (ch) {
|
||||
case 'a':
|
||||
f_all = 1;
|
||||
@ -133,6 +132,11 @@ main(argc, argv)
|
||||
case 'k':
|
||||
jump(argv, "-k", "apropos");
|
||||
/* NOTREACHED */
|
||||
case 's':
|
||||
if (sectionname != NULL)
|
||||
usage();
|
||||
sectionname = optarg;
|
||||
break;
|
||||
case 'S':
|
||||
pathsearch = optarg;
|
||||
break;
|
||||
@ -188,11 +192,14 @@ main(argc, argv)
|
||||
* specified a section and it had absolute (rather than
|
||||
* relative) paths in the man.conf file.
|
||||
*/
|
||||
if (argc > 1 && (section = getlist(*argv)) != NULL) {
|
||||
argv++;
|
||||
argc--;
|
||||
if ((argc > 1 || sectionname != NULL) &&
|
||||
(section = getlist(sectionname ? sectionname : *argv)) != NULL) {
|
||||
if (sectionname == NULL) {
|
||||
argv++;
|
||||
argc--;
|
||||
}
|
||||
abs_section = (TAILQ_FIRST(§ion->list) != NULL &&
|
||||
*(TAILQ_FIRST(§ion->list)->s) == '/');
|
||||
*(TAILQ_FIRST(§ion->list)->s) == '/');
|
||||
} else {
|
||||
section = NULL;
|
||||
abs_section = 0;
|
||||
@ -780,8 +787,7 @@ static void
|
||||
usage()
|
||||
{
|
||||
extern char *__progname;
|
||||
(void)fprintf(stderr,
|
||||
"Usage: %s [-achw] [-C file] [-M path] [-m path] [-S srch] [section] title ...\n",
|
||||
__progname);
|
||||
(void)fprintf(stderr, "Usage: %s [-achw] [-C file] [-M path] [-m path]"
|
||||
"[-S srch] [[-s] section] title ...\n", __progname);
|
||||
exit(1);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user