4.0 man -k not scanning all whatis files

Jim Knutson knutson%sw.MCC.COM at mcc.com
Wed May 17 05:49:35 AEST 1989


There are some valid reasons not to concatenate all the whatis files
together or lump them into one at build time.

If you arrange to install software packages in seperate subtreess (e.g.
package/{bin,man,...}) then a user who does a man -k command may find that
command listed, but may not be able to use "man command" or run command
because his MANPATH and PATH environment variables are not setup to
include the correct path.

Also, if you use any form of the .../old, .../bin, .../new scheme where
there may be multiple commands and man pages with the same name, you would
like the man page to correspond with the binary you are running (requires
careful choices in setting MANPATH).

The following is a shell script which works like man -k but looks at all
the whatis files in MANPATH:

#! /bin/sh
#
# apropos - A man -k (keyword lookup) replacement
#
dirs=`echo ${MANPATH=/usr/man} | sed -e 's;^:;/usr/man:;' \
	-e 's;::;:/usr/man:;' -e 's;:$;:/usr/man;' -e 's;:; ;g'`

while [ "$1" != "" ]; do
	found=0

	for dir in $dirs; do
		if [ -f $dir/whatis ]; then
			if grep -i $1 $dir/whatis; then
				found=1
			fi
		fi
	done

	if [ $found -eq 0 ]; then
		echo $1: nothing appropriate
	fi

	shift
done



More information about the Comp.sys.sun mailing list