Apropos for the 3000s!
G. Murdock Helms
timelord at eos
Tue Feb 7 08:11:02 AEST 1989
Finally....the source for apropos on the 3000s.
Unfortunately, I accidentally walked on my list of people who wanted
copies, so to save time, the file's been posted instead. It's only
two pages long, so don't panic.
To make apropos run, cut on the "cut here" line and install in
/usr/local/bin as 'apropos'. Change the file to be executable.
Create an empty file called "index" in /usr/local/lib. This is the
file that will maintain an index of man commands. To create a new
index, run 'apropos -i' as root.
Apropos has been written to simulate the behaviour of man -k on most
BSD systems. If you have any problems with the file, please let me know,
and I'll do my best to find out what's happening.
This version won't work on the 4Ds. 4Dapropos is on its way.
Good luck, and enjoy.
-Murdock timelord at eos.arc.nasa.gov
---------------------------------CUT HERE--------------------------------------
#!/bin/sh
# -i is used only by cron once a week in the middle of the night
# to build the index. Other flags are incorrect. Apropos
# will only take one argument at a time.
#
# $Header: /usr/u/ssmith/RCS/apropos,v 1.3 88/06/13 12:32:15 ssmith Exp $
#
# $Log: apropos,v $
# Revision 1.3 88/06/13 12:32:15 ssmith
# Exit with message if no arguments (used to hang grep).
# 'Unknown flag' message ( from "Usage....").
# Handle multiple args. ( 'for' loop ).
# Use of grep's exit codes--message if nothing found.
# grep flag from '-w' to '-i' (doug).
# Eliminated pipe to 'more' ( screwed up $?). If desired, run grep in
# a subshell then filter output, e.g., '| fold | more'.
# Awk properly eliminates .B's from SGI graphics manual pages.
#
# Revision 1.2 88/06/13 12:27:37 ssmith
# test for su added 11/9/87
#
# Revision 1.1 88/06/13 12:21:05 ssmith
# Initial revision
#
#
# Database:
index=/usr/local/lib/index
if [ 0 -eq $# ]
then
echo $0 What?;
exit; # echo "Usage: $0 [-i] [word]";
fi
for i
do
case "$i" in
-i) if [ ! -w /bin/su ]
then
echo $USER: You must be root to build index.
exit 1
else build=1
fi
break ;;
-*) echo Unknown flag $i;
exit ;;
*) if grep -i $i $index
then
: ok;
else
echo "\nNothing appropriate: $i \n";
fi
esac
done
# The following was written solely for the purpose of
# getting the one line of info for apropos to use and
# dumping it to a file an a reasonably aesthetic format.
# This is achieved primarily with awk, and it does not hunt
# through the whole file and waste time.
if [ $build ]
then
for x in /usr/man/local/man?/* /usr/man/?_man/man?/*
do
awk '
{name="'`expr $x : '.*/\(.*\)\..*' \| $x`'";}
/^\.TH/ {ver=$3;printf("%-15s",sprintf("%s(%s)",name,ver))}
/^\.SH NAME/ {
getline;
while ($1 !~/^.SH/) {
split($0, s, "\\-");
if ($1 ~ /\.B/ ) {
printf("% s", $2 );
} else {
printf("% s%s", s[1], s[2]);
}
getline;
}
printf("\n");
exit;
} ' $x
done > $index
else
exit;
fi
#
# Acknowledgements: The APROPOS clone was developed by
# G. "Murdock" Helms, with major revisions and bug fixes
# written by Steve Smith. Thanks to Doug Kerr, Khanh Nguyen,
# and Steve Philipson for their help and suggestions. (Thanks guys!)
More information about the Comp.sys.sgi
mailing list