Subject: bin/30539: make wtf a bit more useful: scan PKG_DBDIR
To: None <gnats-admin@netbsd.org, netbsd-bugs@netbsd.org>
From: None <geert.hendrickx@ua.ac.be>
List: netbsd-bugs
Date: 06/16/2005 13:28:00
>Number:         30539
>Category:       bin
>Synopsis:       make wtf a bit more useful: scan PKG_DBDIR
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Thu Jun 16 13:28:00 +0000 2005
>Originator:     Geert Hendrickx
>Release:        netbsd-2
>Organization:
>Environment:
NetBSD mantis 2.0_STABLE NetBSD 2.0_STABLE (MANTIS) #0: Thu Jun 16 04:36:49 CEST 2005  geert@mantis:/usr/obj/src/sys/arch/i386/compile/MANTIS i386
>Description:
wtf checks the acronym database and whatis, in that order.  This patch 
makes it look in PKG_DBDIR as well.  So I can do: 

% wtf is perl
perl: Practical Extraction and Report Language

Nifty eh? :-)  
>How-To-Repeat:
% wtf is perl
Gee...  I don't know what perl means...
>Fix:
--- src/games/wtf/wtf   2003-04-25 21:08:31.000000000 +0200
+++ src/games/wtf/wtf   2005-06-16 15:15:26.000000000 +0200
@@ -57,8 +57,13 @@
                if [ $? -eq 0 ] ; then
                        echo "$1: $ans"
                else
-                       echo "Gee...  I don't know what $1 means..." 1>&2
-                       rv=1
+                       ans=`cat ${PKG_DBDIR:=/var/db/pkg}/${1}-[0-9]*/+COMMENT 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
        fi
        shift