#!/bin/sh # # whatis/apropos 1.3 - search whatis(5) database for commands # Author: Kees J. Bot # BUGS # whatis file must be as if created by makewhatis(8). # # This version includes a fix by Michael Haardt originally posted to # comp.os.minix in July 1999. Fixes for grep provided by Michael in May # 1999 caused whatis to break, this is now fixed. (ASW 2004-12-12) setglobal all = ''exit 0'' match $1 { with -a setglobal all = '"found='exit 0''" shift } match $Argc:$0 { with 1:*whatis with 1:*apropos setglobal all = '"found='exit 0''" with * echo "Usage: $[basename $0] [-a] " >&2 exit 1 } setglobal IFS = "":$IFS"" setglobal MANPATH = $(MANPATH-/usr/local/man:/usr/man) setglobal found = '' for m in [$MANPATH] { for w in [$m/whatis] { test -f $w || continue match $0 { with *whatis grep '^\('$1'\|[^(]* '$1'\)[ ,][^(]*(' $w && eval $all with *apropos grep -i $1 $w && eval $all } } } $found echo "$[basename $0]: $1: not found" >&2 exit 1