blob: 273d482bef15723b25a6e90476b5a19c735dbb61 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
#!/bin/sh
#
# $NetBSD: wtf,v 1.15 2007/08/06 21:14:36 hubertf Exp $
#
# Public domain
#
PROGNAME=`basename $0`
usage() {
echo "usage: $PROGNAME [-f dbfile] [is] <acronym>"
exit 1
}
acronyms=${ACRONYMDB:-`ls /usr/share/misc/acronyms* 2>/dev/null`}
if [ "$acronyms" = "" ]; then
echo "$PROGNAME: acronyms database not found!" >&2
exit 1
fi
args=`getopt f: $*`
if [ $? -ne 0 ]; then
usage
fi
set -- $args
while [ $# -gt 0 ]; do
case "$1" in
-f)
acronyms=$2; shift
;;
--)
shift; break
;;
esac
shift
done
if [ "$1" = "is" ] ; then
shift
fi
if [ $# -lt 1 ] ; then
usage
fi
for f in $acronyms
do
if [ ! -f $f ]; then
echo "$PROGNAME: cannot open acronyms database file \`$f'" >&2
exit 1
fi
done
rv=0
while [ $# -gt 0 ] ; do
# Search acronyms list first
target=`echo $1 | tr '[a-z]' '[A-Z]'`
ans=`fgrep -h $target $acronyms 2>/dev/null \
| sed -ne "\|^$target[[:space:]]|s|^$target[[:space:]]*||p"`
if [ "$ans" != "" ] ; then
echo "$target: $ans"
shift ; continue
fi
# Try whatis(1) next
ans=`whatis $1 2>/dev/null`
if [ $? -eq 0 ] ; then
echo "$ans" | sort -u
shift ; continue
fi
# Try pkg_info(1) next
ans=`pkg_info -qc $1 2> /dev/null`
if [ $? -eq 0 ] ; then
echo "$1: $ans"
shift ; continue
fi
# Try querying pkgsrc's help facility next
if [ -f ../../mk/bsd.pkg.mk ] ; then
ans=`make help topic="$1"`
if [ $? -eq 0 ] ; then
echo "$1: $ans"
shift ; continue
fi
fi
# Give up!
echo "$PROGNAME: I don't know what $1 means!" 1>&2
rv=1
shift
done
exit $rv
|