source: trunk/minix/commands/scripts/whatis.sh@ 10

Last change on this file since 10 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 917 bytes
RevLine 
[9]1#!/bin/sh
2#
3# whatis/apropos 1.3 - search whatis(5) database for commands
4# Author: Kees J. Bot
5# BUGS
6# whatis file must be as if created by makewhatis(8).
7#
8# This version includes a fix by Michael Haardt originally posted to
9# comp.os.minix in July 1999. Fixes for grep provided by Michael in May
10# 1999 caused whatis to break, this is now fixed. (ASW 2004-12-12)
11
12all='exit 0'
13
14case "$1" in
15-a) all="found='exit 0'"
16 shift
17esac
18
19case $#:$0 in
201:*whatis)
21 ;;
221:*apropos)
23 all="found='exit 0'"
24 ;;
25*) echo "Usage: `basename $0` [-a] <keyword>" >&2
26 exit 1
27esac
28
29IFS=":$IFS"
30MANPATH="${MANPATH-/usr/local/man:/usr/man}"
31
32found=
33
34for m in $MANPATH
35do
36 for w in $m/whatis
37 do
38 test -f $w || continue
39
40 case $0 in
41 *whatis)
42 grep '^\('$1'\|[^(]* '$1'\)[ ,][^(]*(' $w && eval $all
43 ;;
44 *apropos)
45 grep -i "$1" $w && eval $all
46 esac
47 done
48done
49
50$found
51
52echo "`basename $0`: $1: not found" >&2
53exit 1
Note: See TracBrowser for help on using the repository browser.