diff options
author | agc <agc> | 2001-02-13 08:18:44 +0000 |
---|---|---|
committer | agc <agc> | 2001-02-13 08:18:44 +0000 |
commit | ac2bd82ce970dbd2a57428060f5af0106da23195 (patch) | |
tree | c5cb0e89a358feb39f93723abd31522d4948cbac | |
parent | da77b84813ea25a636eb869bbf3f35a330dcf870 (diff) | |
download | pkgsrc-ac2bd82ce970dbd2a57428060f5af0106da23195.tar.gz |
Modify pkglocate to only use agrep if the glimpse package is
installed. Otherwise fall back to grep(1), in which case approximate
matching (-p) won't work.
-rwxr-xr-x | pkglocate | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/pkglocate b/pkglocate index d8ac983fb98..f802abbf8a7 100755 --- a/pkglocate +++ b/pkglocate @@ -1,6 +1,6 @@ #! /bin/sh # -# $NetBSD: pkglocate,v 1.2 2000/04/11 16:59:17 jdolecek Exp $ +# $NetBSD: pkglocate,v 1.3 2001/02/13 08:18:44 agc Exp $ # #- # Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -48,7 +48,10 @@ #set -x -pkg_info -qe 'glimpse-*' || (echo "Please install the textproc/glimpse package first."; exit 1) || exit 1 +case `pkg_info -e 'glimpse-*'` in +glimpse-*) grepname=agrep ;; +*) grepname=/usr/bin/grep ;; +esac approx="" igncase="" @@ -58,27 +61,31 @@ while [ $# -gt 1 ]; do case $1 in -i) igncase="-i" ;; -f) files='*/pkg/PLIST*' ;; - -p) approx="-p" ;; + -p) if [ "$grepname" = "agrep" ]; then approx="-p"; fi ;; -v) verbose=yes ;; *) break ;; esac shift done +if [ "$verbose" = "yes" ]; then + echo "===> Using $grepname to find matches" +fi + if [ $# -lt 1 ]; then echo "Usage: pkglocate [-i] [-f] [-p] word" exit 1 fi for d in *; do - if [ ! -f $d/pkg/COMMENT ]; then + if [ ! -d $d/pkg ]; then # not a valid directory continue fi if [ "$verbose" = "yes" ]; then echo "===> Searching category $d" fi - agrep $approx $igncase "$@" $d/$files + $grepname $approx $igncase "$@" $d/$files done exit 0 |