
1: #!/bin/sh 2: # 3: # $NetBSD: wtf,v 1.11 2003/04/25 19:08:31 jmmv Exp $ 4: # 5: # Public domain 6: # 7: 8: usage() { 9: echo "usage: `basename $0` [-f dbfile] [-t type] [is] <acronym>" 10: exit 1 11: } 12: 13: acronyms=${ACRONYMDB:-@wtf_acronymfile@} 14: 15: args=`getopt f:t: $*` 16: if [ $? -ne 0 ]; then 17: usage 18: fi 19: set -- $args 20: while [ $# -gt 0 ]; do 21: case "$1" in 22: -f) 23: acronyms=$2; shift 24: ;; 25: -t) 26: acronyms=@wtf_acronymfile@.$2; shift 27: ;; 28: --) 29: shift; break 30: ;; 31: esac 32: shift 33: done 34: 35: if [ X"$1" = X"is" ] ; then 36: shift 37: fi 38: 39: if [ $# -lt 1 ] ; then 40: usage 41: fi 42: 43: if [ ! -f $acronyms ]; then 44: echo "`basename $0`: cannot open acronyms database file \`$acronyms'" 45: exit 1 46: fi 47: 48: rv=0 49: while [ $# -gt 0 ] ; do 50: target=`echo $1 | tr '[a-z]' '[A-Z]'` 51: ans=`fgrep $target < $acronyms 2>/dev/null \ 52: | sed -ne "\|^$target[[:space:]]|s|^$target[[:space:]]*||p"` 53: if [ "$ans" != "" ] ; then 54: echo "$target: $ans" 55: else 56: ans=`whatis $1 2> /dev/null | egrep "^$1[, ]" 2> /dev/null` 57: if [ $? -eq 0 ] ; then 58: echo "$1: $ans" 59: else 60: echo "Gee... I don't know what $1 means..." 1>&2 61: rv=1 62: fi 63: fi 64: shift 65: done 66: exit $rv