summaryrefslogtreecommitdiffstats
path: root/wtf/wtf
diff options
context:
space:
mode:
authorhubertf <hubertf@NetBSD.org>2005-06-22 20:11:03 +0000
committerhubertf <hubertf@NetBSD.org>2005-06-22 20:11:03 +0000
commitef4d0c168ecc6f29f76a86ed3d1a69c2942c22db (patch)
tree310407eb5ad7dcc34a9c130412c9865d2933234f /wtf/wtf
parent3e39584b24a73f00df65f1e1711ccc868fc80e5a (diff)
downloadbsdgames-darwin-ef4d0c168ecc6f29f76a86ed3d1a69c2942c22db.tar.gz
bsdgames-darwin-ef4d0c168ecc6f29f76a86ed3d1a69c2942c22db.tar.zst
bsdgames-darwin-ef4d0c168ecc6f29f76a86ed3d1a69c2942c22db.zip
* Change program logic to not nest needlessly
* Search all acronyms databases, and don't force the user to know in which category to look (-t is gone) * If an acronym is not found in the database or by whatis(1), also check pkg_info(1). Per PR bin/30539 by Geert Hendrickx (geert.hendrickx@ua.ac.be) OK'd by Julio M. Merino Vidal <jmmv>
Diffstat (limited to 'wtf/wtf')
-rw-r--r--wtf/wtf55
1 files changed, 34 insertions, 21 deletions
diff --git a/wtf/wtf b/wtf/wtf
index 76bfff08..013e66d5 100644
--- a/wtf/wtf
+++ b/wtf/wtf
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# $NetBSD: wtf,v 1.11 2003/04/25 19:08:31 jmmv Exp $
+# $NetBSD: wtf,v 1.12 2005/06/22 20:11:03 hubertf Exp $
#
# Public domain
#
@@ -10,9 +10,9 @@ usage() {
exit 1
}
-acronyms=${ACRONYMDB:-/usr/share/misc/acronyms}
+acronyms=${ACRONYMDB:-`ls /usr/share/misc/acronyms*`}
-args=`getopt f:t: $*`
+args=`getopt f: $*`
if [ $? -ne 0 ]; then
usage
fi
@@ -22,9 +22,6 @@ while [ $# -gt 0 ]; do
-f)
acronyms=$2; shift
;;
- -t)
- acronyms=/usr/share/misc/acronyms.$2; shift
- ;;
--)
shift; break
;;
@@ -32,7 +29,7 @@ while [ $# -gt 0 ]; do
shift
done
-if [ X"$1" = X"is" ] ; then
+if [ "$1" = "is" ] ; then
shift
fi
@@ -40,27 +37,43 @@ if [ $# -lt 1 ] ; then
usage
fi
-if [ ! -f $acronyms ]; then
- echo "`basename $0`: cannot open acronyms database file \`$acronyms'"
- exit 1
-fi
+for f in $acronyms
+do
+ if [ ! -f $f ]; then
+ echo "`basename $0`: cannot open acronyms database file \`$f'" 1>&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 $target < $acronyms 2>/dev/null \
- | sed -ne "\|^$target[[:space:]]|s|^$target[[:space:]]*||p"`
+ ans=`cat $acronyms | fgrep -h $target 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
+ shift ; continue
fi
+
+ # Try whatis(1) next
+ ans=`whatis $1 2>/dev/null`
+ if [ $? -eq 0 ] ; then
+ echo "$ans" | sort | uniq
+ 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
+
+ # Give up!
+ echo "`basename $0`, I don't know what $1 means!" 1>&2
+ rv=1
+
shift
done
exit $rv