Source-Changes-HG archive

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

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



details:   https://anonhg.NetBSD.org/src/rev/dd1c6845b826
branches:  netbsd-2
changeset: 563782:dd1c6845b826
user:      riz <riz%NetBSD.org@localhost>
date:      Tue Jul 05 21:13:14 2005 +0000

description:
Pull up revision 1.12 (requested by hubertf in ticket #2035):
  * 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 e6b56d73aa73 -r dd1c6845b826 games/wtf/wtf
--- a/games/wtf/wtf     Tue Jul 05 21:10:53 2005 +0000
+++ b/games/wtf/wtf     Tue Jul 05 21:13:14 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.4.1 2005/07/05 21:13:14 riz 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