Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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.
  • Loading branch information...
commit 6d17ffdcc400a9c1d0f5a2eff8d66c4f9612ed39 1 parent e93d2ca
agc authored
Showing with 12 additions and 5 deletions.
  1. +12 −5 pkglocate
View
17 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

0 comments on commit 6d17ffd

Please sign in to comment.
Something went wrong with that request. Please try again.