|
Lines 1-9
Link Here
|
| 1 |
#! @BASH@ -- |
1 |
#! @BASH@ -- |
| 2 |
# (X)Emacs: -*- mode: Shell-Script; coding: iso8859-1; -*- |
2 |
# (X)Emacs: -*- mode: Shell-Script; coding: latin-1; -*- |
| 3 |
# @(#)portless.sh,v 1.12 2006/08/30 09:21:22 martin Exp |
3 |
# @(#)portless.sh,v 1.17 2007/09/21 09:23:01 martin Exp |
| 4 |
# Show "pkg-descr" file of matching port(s). |
4 |
# Show "pkg-descr" file of matching port(s). |
| 5 |
# |
5 |
# |
| 6 |
# Copyright (c) 2006 Martin Kammerhofer <mkamm@gmx.net> |
6 |
# Copyright (c) 2006, 2007 Martin Kammerhofer <mkamm@gmx.net> |
| 7 |
# All rights reserved. |
7 |
# All rights reserved. |
| 8 |
# Redistribution and use in source and binary forms, with or without |
8 |
# Redistribution and use in source and binary forms, with or without |
| 9 |
# modification, are permitted provided that the following conditions |
9 |
# modification, are permitted provided that the following conditions |
|
Lines 29-40
Link Here
|
| 29 |
Script=`basename $0` # name of this script |
29 |
Script=`basename $0` # name of this script |
| 30 |
|
30 |
|
| 31 |
# set defaults |
31 |
# set defaults |
| 32 |
for opt in d f I i M m P p W w; do |
32 |
for opt in d f g G I i M m P p W w; do |
| 33 |
eval opt_$opt="" |
33 |
eval opt_$opt="" |
| 34 |
done |
34 |
done |
| 35 |
PORTSDIR=${PORTSDIR:-/usr/ports} |
35 |
PORTSDIR=${PORTSDIR:-/usr/ports} |
| 36 |
PAGER=${PAGER:-less -e} |
36 |
PAGER=${PAGER:-less -e} |
| 37 |
PKGDESCR="pkg-descr" |
37 |
PKGDESCR="pkg-descr" |
|
|
38 |
GREP_PATTERN="" |
| 38 |
filelist="" |
39 |
filelist="" |
| 39 |
rc=0 |
40 |
rc=0 |
| 40 |
|
41 |
|
|
Lines 45-51
Link Here
|
| 45 |
echo >&2 "$Script: $1" |
46 |
echo >&2 "$Script: $1" |
| 46 |
shift |
47 |
shift |
| 47 |
done |
48 |
done |
| 48 |
echo >&2 "usage: $Script [-dfIiMmp | -Ww] [-P pager] 'portglob'..." |
49 |
echo >&2 "usage: $Script [-dfIiMmp | -Ww] [-gG pattern] [-P pager] 'portglob'..." |
| 49 |
exit 64 # EX_USAGE |
50 |
exit 64 # EX_USAGE |
| 50 |
} |
51 |
} |
| 51 |
|
52 |
|
|
Lines 60-74
Link Here
|
| 60 |
} |
61 |
} |
| 61 |
|
62 |
|
| 62 |
# process options |
63 |
# process options |
| 63 |
while getopts "D:dfIiMmpP:Wwx" option |
64 |
while getopts "D:dfG:g:IiMmpP:Wwx" option |
| 64 |
do |
65 |
do |
| 65 |
case "$option" in |
66 |
case "$option" in |
| 66 |
(D) PORTSDIR="$OPTARG";; # undocumented |
67 |
(D) PORTSDIR="$OPTARG";; # undocumented |
| 67 |
(d) addopt d "$PKGDESCR";; |
68 |
(d) addopt d "$PKGDESCR";; |
| 68 |
(f) opt_f="f";; |
69 |
(f) opt_f="f";; |
|
|
70 |
(G) GREP_PATTERN="$OPTARG"; opt_g="G"; opt_G="-F";; |
| 71 |
(g) GREP_PATTERN="$OPTARG"; opt_g="g"; opt_G="";; |
| 69 |
(I) shopt -s nocaseglob || |
72 |
(I) shopt -s nocaseglob || |
| 70 |
usage "option -I needs bash!" |
73 |
usage "option -I needs bash!" |
| 71 |
opt_I="I";; |
74 |
opt_I="-i";; |
| 72 |
(i) addopt i "distinfo";; |
75 |
(i) addopt i "distinfo";; |
| 73 |
(M) addopt M "Makefile";; |
76 |
(M) addopt M "Makefile";; |
| 74 |
(m) addopt m "pkg-message";; |
77 |
(m) addopt m "pkg-message";; |
|
Lines 114-119
Link Here
|
| 114 |
set -- "$@" "$PORTSDIR"$dirglob$portglob/"$f" |
117 |
set -- "$@" "$PORTSDIR"$dirglob$portglob/"$f" |
| 115 |
fi |
118 |
fi |
| 116 |
done |
119 |
done |
|
|
120 |
if [ -n "$opt_g" ]; then |
| 121 |
set -- $(grep -l $opt_G $opt_I -- "$GREP_PATTERN" "$@") |
| 122 |
[ $# = 0 ] && return # grep found no match |
| 123 |
fi |
| 117 |
if [ -n "$opt_W" -o -n "$opt_w" ]; then |
124 |
if [ -n "$opt_W" -o -n "$opt_w" ]; then |
| 118 |
lstrip="" |
125 |
lstrip="" |
| 119 |
[ -n "$opt_W" ] && lstrip=-e\ 's;^.*/\([^/]*/[^/]*\)$;\1;' |
126 |
[ -n "$opt_W" ] && lstrip=-e\ 's;^.*/\([^/]*/[^/]*\)$;\1;' |
|
Lines 128-133
Link Here
|
| 128 |
|
135 |
|
| 129 |
# main |
136 |
# main |
| 130 |
for p in "$@"; do |
137 |
for p in "$@"; do |
|
|
138 |
p=${p%/} # strip a trailing slash |
| 131 |
expr "$p" : ".*[$IFS]" >/dev/null && |
139 |
expr "$p" : ".*[$IFS]" >/dev/null && |
| 132 |
usage "portglob '$p' contains whitespace!" |
140 |
usage "portglob '$p' contains whitespace!" |
| 133 |
case "$p" in |
141 |
case "$p" in |