summaryrefslogtreecommitdiff
path: root/pkglocate
diff options
context:
space:
mode:
authoragc <agc@pkgsrc.org>2001-02-13 08:18:44 +0000
committeragc <agc@pkgsrc.org>2001-02-13 08:18:44 +0000
commit957ef127a28974b0e99430cccc0dbd48f0f22e67 (patch)
treec5cb0e89a358feb39f93723abd31522d4948cbac /pkglocate
parent3b9d2607160433d0b31bf848fac920405501f27a (diff)
downloadpkgsrc-957ef127a28974b0e99430cccc0dbd48f0f22e67.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.
Diffstat (limited to 'pkglocate')
-rwxr-xr-xpkglocate17
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