Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-3]: src/games/wtf Pull up revision 1.12 (requested by hubertf in ...



details:   https://anonhg.NetBSD.org/src/rev/8e79b450eef9
branches:  netbsd-3
changeset: 576437:8e79b450eef9
user:      tron <tron%NetBSD.org@localhost>
date:      Sat Jul 02 23:25:00 2005 +0000

description:
Pull up revision 1.12 (requested by hubertf in ticket #506):
  * 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@localhost)
OK'd by Julio M. Merino Vidal <jmmv>

diffstat:

 games/wtf/wtf |  55 ++++++++++++++++++++++++++++++++++---------------------
 1 files changed, 34 insertions(+), 21 deletions(-)

diffs (100 lines):

diff -r 3c25c4201745 -r 8e79b450eef9 games/wtf/wtf
--- a/games/wtf/wtf     Sat Jul 02 23:23:20 2005 +0000
+++ b/games/wtf/wtf     Sat Jul 02 23:25:00 2005 +0000
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-#      $NetBSD: wtf,v 1.11 2003/04/25 19:08:31 jmmv Exp $
+#      $NetBSD: wtf,v 1.11.6.1 2005/07/02 23:25:00 tron Exp $
 #
 # Public domain
 #
@@ -10,9 +10,9 @@
        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 @@
                -f)
                        acronyms=$2; shift
                        ;;
-               -t)
-                       acronyms=/usr/share/misc/acronyms.$2; shift
-                       ;;
                --)
                        shift; break
                        ;;
@@ -32,7 +29,7 @@
        shift
 done
 
-if [ X"$1" = X"is" ] ; then
+if [ "$1" = "is" ] ; then
        shift
 fi
 
@@ -40,27 +37,43 @@
        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



Home | Main Index | Thread Index | Old Index