From 69a71301db0e381427ac8afc2db8d419661e6d5e Mon Sep 17 00:00:00 2001 From: "Bruce A. Mah" Date: Fri, 20 Oct 2000 06:16:18 +0000 Subject: [PATCH] Add -L option to limit the package status characters the user *doesn't* want to see. Submitted by: Doug Barton --- usr.sbin/pkg_install/version/pkg_version.1 | 13 ++++++++++- usr.sbin/pkg_install/version/pkg_version.pl | 26 +++++++++++++++++---- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/usr.sbin/pkg_install/version/pkg_version.1 b/usr.sbin/pkg_install/version/pkg_version.1 index 741ef6264bc..9e2113580d2 100644 --- a/usr.sbin/pkg_install/version/pkg_version.1 +++ b/usr.sbin/pkg_install/version/pkg_version.1 @@ -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. diff --git a/usr.sbin/pkg_install/version/pkg_version.pl b/usr.sbin/pkg_install/version/pkg_version.pl index 59bd29e5078..b4852c05cd9 100755 --- a/usr.sbin/pkg_install/version/pkg_version.pl +++ b/usr.sbin/pkg_install/version/pkg_version.pl @@ -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; } }