aboutsummaryrefslogtreecommitdiff
path: root/ports-mgmt/portless
diff options
context:
space:
mode:
authorErwin Lansing <erwin@FreeBSD.org>2006-06-14 18:59:01 +0000
committerErwin Lansing <erwin@FreeBSD.org>2006-06-14 18:59:01 +0000
commit964ee9f48a6a9074cda1e85d37c3c06bac3d6c70 (patch)
tree1546b130fd584480e78c263957fe756129a20fff /ports-mgmt/portless
parentb8d08821dc63586a20658815ce7f447d20088783 (diff)
downloadports-964ee9f48a6a9074cda1e85d37c3c06bac3d6c70.tar.gz
ports-964ee9f48a6a9074cda1e85d37c3c06bac3d6c70.zip
Notes
Diffstat (limited to 'ports-mgmt/portless')
-rw-r--r--ports-mgmt/portless/Makefile2
-rw-r--r--ports-mgmt/portless/files/portless.19
-rw-r--r--ports-mgmt/portless/files/portless.sh70
-rw-r--r--ports-mgmt/portless/pkg-descr12
4 files changed, 64 insertions, 29 deletions
diff --git a/ports-mgmt/portless/Makefile b/ports-mgmt/portless/Makefile
index e960e17535c5..c54b2479d750 100644
--- a/ports-mgmt/portless/Makefile
+++ b/ports-mgmt/portless/Makefile
@@ -6,7 +6,7 @@
#
PORTNAME= portless
-PORTVERSION= 0.1.1
+PORTVERSION= 0.2
CATEGORIES= misc
MASTER_SITES= # empty
DISTFILES= # none
diff --git a/ports-mgmt/portless/files/portless.1 b/ports-mgmt/portless/files/portless.1
index e3ba9076418f..07e98358c91a 100644
--- a/ports-mgmt/portless/files/portless.1
+++ b/ports-mgmt/portless/files/portless.1
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)portless.1,v 1.1 2006/06/08 10:10:56 martin Exp
+.\" @(#)portless.1,v 1.2 2006/06/14 12:44:25 martin Exp
.\"
.\" Note: The date here should be updated whenever a non-trivial
.\" change is made to the manual page.
@@ -94,12 +94,13 @@ command uses the
.It Pa /usr/ports/*/*/*
.El
.Sh EXAMPLES
-The following is an example of a typical usage
-of the
+The following are examples of typical usage of the
.Nm
command:
.Pp
-.Dl "portless gcc\e*"
+.Dl "portless cvsweb\e*"
+.Dl "portless lang/\e*doc"
+.Dl "portless 'www/*python*'"
.Sh AUTHOR
The
.Nm
diff --git a/ports-mgmt/portless/files/portless.sh b/ports-mgmt/portless/files/portless.sh
index 966758676a50..3863e680b7e9 100644
--- a/ports-mgmt/portless/files/portless.sh
+++ b/ports-mgmt/portless/files/portless.sh
@@ -1,6 +1,6 @@
#! /bin/sh --
# (X)Emacs: -*- mode: Shell-Script; coding: iso8859-1; -*-
-# @(#)portless.sh,v 1.3 2006/06/08 10:10:56 martin Exp
+# @(#)portless.sh,v 1.7 2006/06/14 13:02:37 martin Exp
# Show "pkg-descr" file of matching port(s).
#
# Copyright (c) 2006 Martin Kammerhofer <mkamm@gmx.net>
@@ -29,10 +29,14 @@
Script=`basename $0` # name of this script
# set defaults
-opt_f=""
+for opt in d f i M m p; do
+ eval opt_$opt=""
+done
PORTSDIR=${PORTSDIR:-/usr/ports}
PAGER=${PAGER:-less -e}
PKGDESCR="pkg-descr"
+filelist=""
+rc=0
# print usage message to stderr and exit
usage()
@@ -45,48 +49,76 @@ usage()
exit 64 # EX_USAGE
}
+fatal() { echo >&2 "$Script: $*"; exit 70; } # EX_SOFTWARE
+
+# Add file $2 corresponding to option $1 to $filelist.
+# Do not add any file twice.
+addopt()
+{
+ eval "[ -n \"\$opt_$1\" ] && return; opt_$1='$1' || fatal 'addopt $*'"
+ filelist="$filelist $2"
+}
+
# process options
-while getopts "D:dfiMmpP:" option
+while getopts "D:dfiMmpP:x" option
do
case "$option" in
- (D) PORTSDIR="$OPTARG";;
- (d) PKGDESCR="pkg-descr";;
+ (D) PORTSDIR="$OPTARG";; # undocumented
+ (d) addopt d "$PKGDESCR";;
(f) opt_f="f";;
- (i) PKGDESCR="distinfo";;
- (M) PKGDESCR="Makefile";;
- (m) PKGDESCR="pkg-message";;
- (p) PKGDESCR="pkg-plist";;
+ (i) addopt i "distinfo";;
+ (M) addopt M "Makefile";;
+ (m) addopt m "pkg-message";;
+ (p) addopt p "pkg-plist";;
(P) PAGER="$OPTARG";;
+ (x) set -x;; # undocumented
(*) usage;;
esac
done
shift $(($OPTIND - 1))
+[ -d "$PORTSDIR" ] || fatal "No such directory '$PORTSDIR'"
+[ -n "$filelist" ] || filelist="$PKGDESCR"
# there must be at least one argument
if [ $# = 0 ]; then
usage
fi
+# View $PORTSDIR$1$2/{$filelist} with $PAGER.
+# Always glob $1 but do not glob $2 when option -f was given.
+# (Slightly complicated because /bin/sh may not understand
+# csh-like {file1,file2} glob patterns.)
+page() {
+ [ $# = 2 ] || fatal "page $*"
+ dirglob=$1
+ portglob=$2
+ shift 2
+ for f in $filelist; do
+ if [ -n "$opt_f" ]; then
+ set -- "$@" "$PORTSDIR"$dirglob"$portglob/$f"
+ else
+ set -- "$@" "$PORTSDIR"$dirglob$portglob/"$f"
+ fi
+ done
+ $PAGER "$@" || { rc=$?; return $rc; } # remember last error code
+}
+
# main
for p in "$@"; do
+ set -- $p
+ [ $# != 1 ] && usage "portglob '$p' contains whitespace!"
case "$p" in
(*/*/*)
usage "portglob '$p' contains more than one slash!";;
(*/*)
- if [ -n "$opt_f" ]; then
- $PAGER "$PORTSDIR/$p/$PKGDESCR"
- else
- $PAGER "$PORTSDIR"/$p/"$PKGDESCR"
- fi;;
+ page "/" "$p";;
(*)
- if [ -n "$opt_f" ]; then
- $PAGER "$PORTSDIR"/[a-z]*/"$p/$PKGDESCR"
- else
- $PAGER "$PORTSDIR"/[a-z]*/$p/"$PKGDESCR"
- fi;;
+ page "/[a-z]*/" "$p";;
esac
done
+exit $rc
+
#EOF#
diff --git a/ports-mgmt/portless/pkg-descr b/ports-mgmt/portless/pkg-descr
index f50213ae140d..c99470345339 100644
--- a/ports-mgmt/portless/pkg-descr
+++ b/ports-mgmt/portless/pkg-descr
@@ -1,9 +1,11 @@
-portless is a small shell script which lets FreeBSD users quickly browse
-port descriptions given the port's name or a glob. Basically to view
-the descriptions of GCC (related) ports you type
+The portless utility is a small shell script which lets FreeBSD users
+quickly browse port descriptions given the port's name or a
+glob. Basically to view the descriptions of GCC (related) ports you
+simply type
portless gcc\*
-and portless will display the descriptions of all gcc* ports.
-There are options to display the postinstall messages or Makefiles instead.
+and it will display all descriptions of the gcc* ports.
+There are options to display the port's postinstall message or
+Makefile too. A manpage is included.
- Martin Kammerhofer
mkamm@gmx.net