Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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 1 changed file with 12 additions and 5 deletions. Show diff stats Hide diff stats

  1. +12 5 pkglocate
17 pkglocate
... ... @@ -1,6 +1,6 @@
1 1 #! /bin/sh
2 2 #
3   -# $NetBSD: pkglocate,v 1.2 2000/04/11 16:59:17 jdolecek Exp $
  3 +# $NetBSD: pkglocate,v 1.3 2001/02/13 08:18:44 agc Exp $
4 4 #
5 5 #-
6 6 # Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -48,7 +48,10 @@
48 48
49 49 #set -x
50 50
51   -pkg_info -qe 'glimpse-*' || (echo "Please install the textproc/glimpse package first."; exit 1) || exit 1
  51 +case `pkg_info -e 'glimpse-*'` in
  52 +glimpse-*) grepname=agrep ;;
  53 +*) grepname=/usr/bin/grep ;;
  54 +esac
52 55
53 56 approx=""
54 57 igncase=""
@@ -58,27 +61,31 @@ while [ $# -gt 1 ]; do
58 61 case $1 in
59 62 -i) igncase="-i" ;;
60 63 -f) files='*/pkg/PLIST*' ;;
61   - -p) approx="-p" ;;
  64 + -p) if [ "$grepname" = "agrep" ]; then approx="-p"; fi ;;
62 65 -v) verbose=yes ;;
63 66 *) break ;;
64 67 esac
65 68 shift
66 69 done
67 70
  71 +if [ "$verbose" = "yes" ]; then
  72 + echo "===> Using $grepname to find matches"
  73 +fi
  74 +
68 75 if [ $# -lt 1 ]; then
69 76 echo "Usage: pkglocate [-i] [-f] [-p] word"
70 77 exit 1
71 78 fi
72 79
73 80 for d in *; do
74   - if [ ! -f $d/pkg/COMMENT ]; then
  81 + if [ ! -d $d/pkg ]; then
75 82 # not a valid directory
76 83 continue
77 84 fi
78 85 if [ "$verbose" = "yes" ]; then
79 86 echo "===> Searching category $d"
80 87 fi
81   - agrep $approx $igncase "$@" $d/$files
  88 + $grepname $approx $igncase "$@" $d/$files
82 89 done
83 90
84 91 exit 0

0 comments on commit 6d17ffd

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