diff options
author | agc <agc@pkgsrc.org> | 2000-02-21 12:38:54 +0000 |
---|---|---|
committer | agc <agc@pkgsrc.org> | 2000-02-21 12:38:54 +0000 |
commit | 1ae3b11d04162d6978c0ebe70483d473b8a061fa (patch) | |
tree | d648b094b2e509a8425f20e4864a883869612713 | |
parent | 3e799d0d3d0385cec3f1ea085bcdbafbde9280de (diff) | |
download | pkgsrc-1ae3b11d04162d6978c0ebe70483d473b8a061fa.tar.gz |
Add a small shell script to locate words in either the PLIST files or
the package description files, using approximate matching.
# Locate words in description, or files in the PLISTs
#
# [-i] == ignore case when searching
# [-f] == look for a file, rather than a word or phrase
# [-p] == use approximate matching
# [-v] == be verbose
#
# Usage: pkglocate [-i] [-p] [-f] [-v] word
-rwxr-xr-x | pkglocate | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/pkglocate b/pkglocate new file mode 100755 index 00000000000..e51c14a7d97 --- /dev/null +++ b/pkglocate @@ -0,0 +1,84 @@ +#! /bin/sh +# +# $NetBSD: pkglocate,v 1.1 2000/02/21 12:38:54 agc Exp $ +# +#- +# Copyright (c) 2000 The NetBSD Foundation, Inc. +# All rights reserved. +# +# This code is derived from software contributed to The NetBSD Foundation +# by Alistair G. Crooks. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. All advertising materials mentioning features or use of this software +# must display the following acknowledgement: +# This product includes software developed by the NetBSD +# Foundation, Inc. and its contributors. +# 4. Neither the name of The NetBSD Foundation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS +# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +# Locate words in description, or files in the PLISTs +# +# [-i] == ignore case when searching +# [-f] == look for a file, rather than a word or phrase +# [-p] == use approximate matching +# [-v] == be verbose +# +# Usage: pkglocate [-i] [-p] [-f] [-v] word + +#set -x + +pkg_info -qe 'glimpse-*' || (echo "Please install the textproc/glimpse package first."; exit 1) + +approx="" +igncase="" +verbose=no +files='*/pkg/DESCR' +while [ $# -gt 1 ]; do + case $1 in + -i) igncase="-i" ;; + -f) files='*/pkg/PLIST*' ;; + -p) approx="-p" ;; + -v) verbose=yes ;; + *) break ;; + esac + shift +done + +if [ $# -lt 1 ]; then + echo "Usage: pkglocate [-i] [-f] [-p] word" + exit 1 +fi + +for d in *; do + if [ ! -f $d/pkg/COMMENT ]; then + # not a valid directory + continue + fi + if [ "$verbose" = "yes" ]; then + echo "===> Searching category $d" + fi + agrep $approx $igncase "$@" $d/$files +done + +exit 0 |