24c2b45c15
One can do `wtf -t comp pci' and it will use /usr/share/misc/acronyms.comp to search the acronym as usual.
67 lines
1.1 KiB
Bash
67 lines
1.1 KiB
Bash
#!/bin/sh
|
|
#
|
|
# $NetBSD: wtf,v 1.11 2003/04/25 19:08:31 jmmv Exp $
|
|
#
|
|
# Public domain
|
|
#
|
|
|
|
usage() {
|
|
echo "usage: `basename $0` [-f dbfile] [-t type] [is] <acronym>"
|
|
exit 1
|
|
}
|
|
|
|
acronyms=${ACRONYMDB:-/usr/share/misc/acronyms}
|
|
|
|
args=`getopt f:t: $*`
|
|
if [ $? -ne 0 ]; then
|
|
usage
|
|
fi
|
|
set -- $args
|
|
while [ $# -gt 0 ]; do
|
|
case "$1" in
|
|
-f)
|
|
acronyms=$2; shift
|
|
;;
|
|
-t)
|
|
acronyms=/usr/share/misc/acronyms.$2; shift
|
|
;;
|
|
--)
|
|
shift; break
|
|
;;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
if [ X"$1" = X"is" ] ; then
|
|
shift
|
|
fi
|
|
|
|
if [ $# -lt 1 ] ; then
|
|
usage
|
|
fi
|
|
|
|
if [ ! -f $acronyms ]; then
|
|
echo "`basename $0`: cannot open acronyms database file \`$acronyms'"
|
|
exit 1
|
|
fi
|
|
|
|
rv=0
|
|
while [ $# -gt 0 ] ; do
|
|
target=`echo $1 | tr '[a-z]' '[A-Z]'`
|
|
ans=`fgrep $target < $acronyms 2>/dev/null \
|
|
| sed -ne "\|^$target[[:space:]]|s|^$target[[:space:]]*||p"`
|
|
if [ "$ans" != "" ] ; then
|
|
echo "$target: $ans"
|
|
else
|
|
ans=`whatis $1 2> /dev/null | egrep "^$1[, ]" 2> /dev/null`
|
|
if [ $? -eq 0 ] ; then
|
|
echo "$1: $ans"
|
|
else
|
|
echo "Gee... I don't know what $1 means..." 1>&2
|
|
rv=1
|
|
fi
|
|
fi
|
|
shift
|
|
done
|
|
exit $rv
|