Line | |
---|
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 |
|
---|
12 | all='exit 0'
|
---|
13 |
|
---|
14 | case "$1" in
|
---|
15 | -a) all="found='exit 0'"
|
---|
16 | shift
|
---|
17 | esac
|
---|
18 |
|
---|
19 | case $#:$0 in
|
---|
20 | 1:*whatis)
|
---|
21 | ;;
|
---|
22 | 1:*apropos)
|
---|
23 | all="found='exit 0'"
|
---|
24 | ;;
|
---|
25 | *) echo "Usage: `basename $0` [-a] <keyword>" >&2
|
---|
26 | exit 1
|
---|
27 | esac
|
---|
28 |
|
---|
29 | IFS=":$IFS"
|
---|
30 | MANPATH="${MANPATH-/usr/local/man:/usr/man}"
|
---|
31 |
|
---|
32 | found=
|
---|
33 |
|
---|
34 | for m in $MANPATH
|
---|
35 | do
|
---|
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
|
---|
48 | done
|
---|
49 |
|
---|
50 | $found
|
---|
51 |
|
---|
52 | echo "`basename $0`: $1: not found" >&2
|
---|
53 | exit 1
|
---|
Note:
See
TracBrowser
for help on using the repository browser.