Subject: bin/365: $MANPATH vs two-arg man(1)
To: None <gnats-admin>
From: der Mouse <mouse@Collatz.McRCIM.McGill.EDU>
List: netbsd-bugs
Date: 07/25/1994 18:05:05
>Number:         365
>Category:       bin
>Synopsis:       man(1) ignores the section argument if $MANPATH is set
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    gnats-admin (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jul 25 18:05:04 1994
>Originator:     der Mouse
	Sources supped from sun-lamp just this afternoon (1994 July 25)
	sccsid strings:
		config.c:static char sccsid[] = "@(#)config.c	8.5 (Berkeley) 11/26/93";
		man.c:static char sccsid[] = "@(#)man.c	8.13 (Berkeley) 12/20/93";
	man(1) ignores the section argumennt when a MANPATH environment
	variable exists.  (It still does minimal checking, to tell the
	difference between a section argument and another man page
	Set a MANPATH environment variable (eg,
	"setenv MANPATH /usr/share/man").  Ask for a man page that
	exists in more than one section, with an explicit section
	argument.  Notice you always get the same one, regardless of
	what the section argument is, even if the man page doesn't
	exist in that section.

	Unset the MANPATH variable.  Repeat the attempts, and notice
	that this time man pays attention to the section argument.


		[Callisto] 9> mkdir /tmp/man
		[Callisto] 10> cp /usr/src/usr.bin/man/* /tmp/man
		[Callisto] 11> cd /tmp/man
		[Callisto] 12> make
		cc -O   -c config.c
		cc -O   -c man.c
		cc   -o man config.o man.o 
		nroff -mandoc man.1 > man.0
		nroff -mandoc man.conf.5 > man.conf.0
		[Callisto] 13> setenv MANPATH /usr/share/man
		[Callisto] 14> /tmp/man/man 5 crontab
	(at this point, $PAGER fires up, displaying crontab(1))
		[Callisto] 15> unsetenv MANPATH
		[Callisto] 16> /tmp/man/man 5 crontab
	(at this point, $PAGER fires up, displaying crontab(5))

	This also happens if MANPATH is unset but the -M flag is used,
	as in "/tmp/man/man -M /usr/share/man 5 crontab" in the sample
	above.  -m does not provoke the misbehavior.
	Not known, sorry.  I suspect the code around lines 150-275 of
	man.c, but haven't looked at it in enough detail to feel I know
	what's going on there.