Received: (at submit) by bugs.debian.org; 11 Nov 1999 22:09:24 +0000 Received: (qmail 4192 invoked from network); 11 Nov 1999 22:09:22 -0000 Received: from vasquez.zip.com.au (203.12.97.41) by master.debian.org with SMTP; 11 Nov 1999 22:09:22 -0000 Received: from localhost (banana46.zip.com.au [61.8.30.78]) by vasquez.zip.com.au (8.9.2/8.9.1) with ESMTP id JAA04516 for ; Fri, 12 Nov 1999 09:09:11 +1100 (EST) Received: from gg by localhost with local (Exim 2.05 #1 (Debian)) id 11m2ep-0001iO-00; Fri, 12 Nov 1999 08:25:31 +1000 To: submit@bugs.debian.org Subject: Tweaking dlocate to accept some more wildcards [PATCH] From: Kevin Ryde Date: 12 Nov 1999 08:25:30 +1000 Message-ID: <87aeokekdh.fsf@zip.com.au> Lines: 28 User-Agent: Gnus/5.070099 (Pterodactyl Gnus v0.99) Emacs/20.3 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Package: dlocate Version: 0.5 Severity: wishlist I think it might not be too difficult to get dlocate to support shell style wildcards in package names, and to better support them in -S search patterns. Attached is a patch with an example -L, and a suggested -S. If the idea in -L is good I'll do it for the other options if you like. The pattern I used in the locate for -S depends on ": " not being in a filename, which should always be true. The variation for patterns with a leading / is based on what I think dpkg -S does, and in any case it's fairly sensible to think "/bin/foo" is a full path and should be matched exactly, ie. /usr/bin/foo or /bin/foo.real wouldn't be matched. I compared -S output with dpkg for a few patterns and got the same results, apart from sort order, diversions, and the format for directories that are in multiple packages. An idiosyncracy of dpkg -S (in slink at least) is that a pattern like "[xy]font" or "?fonts" doesn't work because it starts with a metacharacter, you have to give "*[xy]font*" or "*?fonts*". But dlocate -S will work on plain "[xy]font" and "?fonts". --=-=-= Content-Disposition: attachment; filename=dlocate.diff --- dlocate.old Thu Nov 11 17:42:45 1999 +++ dlocate Thu Nov 11 21:52:31 1999 @@ -47,7 +47,7 @@ ;; esac -PKG=$1 +PKG="$1" [ -z "$1" ] && PKG="$OPTION" while [ -n "$PKG" ] ; do @@ -64,14 +64,19 @@ grep "$1" $DPKGLIST ;; "-L") - if [ -e $DPKG_INFO/$PKG.list ] ; then - cat $DPKG_INFO/$PKG.list - else - echo Package \"$PKG\" not installed. - fi + for i in $DPKG_INFO/$PKG.list ; do + if [ -e "$i" ] ; then + cat $DPKG_INFO/$PKG.list + else + echo Package \"$PKG\" not installed. + fi + done ;; "-S") - $LOCATE -d $DLOCATEDB $PKG | grep ":.*$PKG.*" + case "$PKG" in + /*) $LOCATE -d $DLOCATEDB "*: $PKG" ;; + *) $LOCATE -d $DLOCATEDB "*: *$PKG*" ;; + esac ;; "-s") if [ -e $DPKG_INFO/$PKG.list ] ; then @@ -139,7 +144,7 @@ esac shift -PKG=$1 +PKG="$1" done --=-=-=--