Add -L option to limit the package status characters the user *doesn't*
want to see. Submitted by: Doug Barton <DougB@gorean.org>
This commit is contained in:
parent
65ea861a3e
commit
69a71301db
@ -34,6 +34,7 @@
|
||||
.Nm pkg_version
|
||||
.Op Fl cdhv
|
||||
.Op Fl l Ar limchar
|
||||
.Op Fl L Ar limchar
|
||||
.Op Ar index
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
@ -93,6 +94,15 @@ Note that because some of the status flag characters are also special
|
||||
to the shell, it is best to quote
|
||||
.Ar limchar
|
||||
with single quotes.
|
||||
.It Fl L
|
||||
Limit the output to those packages whose status flag doesn't match
|
||||
.Ar limchar .
|
||||
You may specify more than one character to match in
|
||||
.Ar limchar .
|
||||
Note that because some of the status flag characters are also special
|
||||
to the shell, it is best to quote
|
||||
.Ar limchar
|
||||
with single quotes.
|
||||
.It Fl v
|
||||
Enable verbose output. Verbose output includes some English-text
|
||||
interpretations of the version number comparisons, as well as the
|
||||
@ -149,7 +159,8 @@ suggestions, and then cut-and-paste (or retype) the commands you want to run.
|
||||
.Sh CONTRIBUTORS
|
||||
.An Nik Clayton Aq nik@FreeBSD.org ,
|
||||
.An Dominic Mitchell Aq dom@palmerharvey.co.uk ,
|
||||
.An Mark Ovens Aq marko@FreeBSD.org
|
||||
.An Mark Ovens Aq marko@FreeBSD.org ,
|
||||
.An Doug Barton Aq DougB@gorean.org
|
||||
.Sh BUGS
|
||||
There should be a better way of dealing with packages that
|
||||
can have more than one installed version.
|
||||
|
@ -48,6 +48,7 @@ $DebugFlag = 0;
|
||||
$VerboseFlag = 0;
|
||||
$CommentChar = "#";
|
||||
$LimitFlag = "";
|
||||
$PreventFlag = "";
|
||||
|
||||
#
|
||||
# CompareNumbers
|
||||
@ -196,7 +197,8 @@ Usage: pkg_version [-c] [-d debug] [-h] [-v] [index]
|
||||
-c Show commands to update installed packages
|
||||
-d debug Debugging output (debug controls level of output)
|
||||
-h Help (this message)
|
||||
-l limchar Limit output
|
||||
-l limchar Limit output to status flags that match
|
||||
-L limchar Limit output to status flags that DON'T match
|
||||
-v Verbose output
|
||||
index URL or filename of index file
|
||||
(Default is $IndexFile)
|
||||
@ -206,7 +208,7 @@ EOF
|
||||
#
|
||||
# Parse command-line arguments, deal with them
|
||||
#
|
||||
if (!getopts('cdhl:v') || ($opt_h)) {
|
||||
if (!getopts('cdhl:L:v') || ($opt_h)) {
|
||||
&PrintHelp();
|
||||
exit;
|
||||
}
|
||||
@ -222,6 +224,9 @@ if ($opt_d) {
|
||||
if ($opt_l) {
|
||||
$LimitFlag = $opt_l;
|
||||
}
|
||||
if ($opt_L) {
|
||||
$PreventFlag = $opt_L;
|
||||
}
|
||||
if ($opt_v) {
|
||||
$VerboseFlag = 1;
|
||||
}
|
||||
@ -344,10 +349,21 @@ foreach $packageName (sort keys %currentPackages) {
|
||||
$Comment = "unknown in index";
|
||||
}
|
||||
|
||||
if ($LimitFlag) {
|
||||
write if $versionCode =~ m/[$LimitFlag]/o;
|
||||
} else {
|
||||
# Having figured out what to print, now determine, based on the
|
||||
# $LimitFlag and $PreventFlag variables, if we should print or not.
|
||||
if ((not $LimitFlag) and (not $PreventFlag)) {
|
||||
write;
|
||||
} elsif ($PreventFlag) {
|
||||
if ($versionCode !~ m/[$PreventFlag]/o) {
|
||||
if (not $LimitFlag) {
|
||||
write;
|
||||
} else {
|
||||
write if $versionCode =~ m/[$LimitFlag]/o;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
# Must mean that there is a LimitFlag
|
||||
write if $versionCode =~ m/[$LimitFlag]/o;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user