Subject: Re: how to get man not to use cat pages?
To: Jeremy C. Reed <reed@reedmedia.net>
From: Mike M. Volokhov <mishka@intostroy.com>
List: netbsd-users
Date: 02/16/2006 21:09:30
On Thu, 16 Feb 2006 09:24:32 -0800 (PST)
"Jeremy C. Reed" <reed@reedmedia.net> wrote:

> On Thu, 16 Feb 2006, Mike M. Volokhov wrote:
> 
> > I believe you can got results by adjusting _subdir in /etc/man.conf
> > file. Please see man.conf(5) for details.
> 
> I didn't want to use man.conf for this (as I mentioned).
> 
> Maybe a command-line switch could be added to override the _subdir. If I 
> don't find an answer I will check latest groff source and maybe make a 
> patch and submit to groff developers.

Looking to the man(1) sources I've found it use config file settings
unconditionally. With the following trivial patch you may override
_subdir value using "-u subdir_list" or MANSUBDIR environment variable.
For example:

$ ./man -w man
/usr/share/man//cat1/man.0
/usr/share/man//man1/man.1
/usr/share/man//cat7/man.0
/usr/share/man//man7/man.7
$ ./man -u man1:man7 -w man
/usr/share/man//man1/man.1
/usr/share/man//man7/man.7
$ ./man -u man7:man1 -w man
/usr/share/man//man7/man.7
/usr/share/man//man1/man.1
$ ./man -u none -w man
man: no entry for man in the manual.

--
Mishka.


Index: man.c
===================================================================
RCS file: /tnp/netbsd/cvsroot/src/usr.bin/man/man.c,v
retrieving revision 1.31
diff -u -r1.31 man.c
--- man.c	5 Jan 2004 23:23:36 -0000	1.31
+++ man.c	16 Feb 2006 21:01:12 -0000
@@ -86,7 +86,7 @@
 	glob_t pg;
 	size_t len;
 	int ch, f_cat, f_how, found, abs_section;
-	char **ap, *cmd, *p, *p_add, *p_path;
+	char **ap, *cmd, *p, *p_add, *p_path, *p_subp;
 	const char *machine, *pager, *conffile, *pathsearch, *sectionname;
 	char buf[MAXPATHLEN * 2];
 
@@ -95,8 +95,8 @@
 #endif
 
 	f_cat = f_how = 0;
-	sectionname = pathsearch = conffile = p_add = p_path = NULL;
-	while ((ch = getopt(argc, argv, "-aC:cfhkM:m:P:s:S:w")) != -1)
+	sectionname = pathsearch = conffile = p_add = p_path = p_subp = NULL;
+	while ((ch = getopt(argc, argv, "-aC:cfhkM:m:P:s:S:u:w")) != -1)
 		switch (ch) {
 		case 'a':
 			f_all = 1;
@@ -136,6 +136,9 @@
 		case 'S':
 			pathsearch = optarg;
 			break;
+		case 'u':
+			p_subp = strdup(optarg);
+			break;
 		case 'w':
 			f_all = f_where = 1;
 			break;
@@ -178,6 +181,10 @@
 	/* create an empty _default list if the config file didn't have one */
 	defp = getlist("_default", 1);
 
+	/* if -u wasn't specified, check for MANSUBDIR */
+	if (p_subp == NULL)
+		p_subp = getenv("MANSUBDIR");
+
 	/* if -M wasn't specified, check for MANPATH */
 	if (p_path == NULL)
 		p_path = getenv("MANPATH");
@@ -201,7 +208,17 @@
 	}
 
 	/* get subdir list */
-	subp = getlist("_subdir", 1);
+	subp = getlist("_new_subpath", 1);
+	if (p_subp) {
+		/* obtain subpaths from the command line */
+		for (; (p = strtok(p_subp, ":")) != NULL; p_subp = NULL) {
+			snprintf(buf, sizeof(buf), "%s", p);
+			addentry(subp, buf, 0);
+		}
+	} else {
+		/* use config file settings by default */
+		subp = getlist("_subdir", 0);
+	}
 
 	/*
 	 * now that we have all the inputs we must generate a search path.
@@ -803,6 +820,7 @@
 {
 
 	(void)fprintf(stderr, "usage: %s [-achw] [-C file] [-M path] [-m path]"
-	    "[-S srch] [[-s] section] title ...\n", getprogname());
+	    " [-S srch] [[-s] section] [-u subdir] title ...\n",
+	    getprogname());
 	exit(1);
 }