From a4ca4e84c424f3799326946f6280365009b0dfdd Mon Sep 17 00:00:00 2001 From: obrien Date: Mon, 18 Oct 2004 05:34:54 +0000 Subject: Add a -q flag to pkg_version. It suppresses the output of <,=,>. This makes it possible to "portupgrade `pkg_version -q -l '<'`". --- usr.sbin/pkg_install/info/info.h | 1 - usr.sbin/pkg_install/info/main.c | 1 - usr.sbin/pkg_install/lib/global.c | 1 + usr.sbin/pkg_install/lib/lib.h | 1 + usr.sbin/pkg_install/version/main.c | 6 +++++- usr.sbin/pkg_install/version/perform.c | 6 +++--- usr.sbin/pkg_install/version/pkg_version.1 | 15 +++++++++++++-- 7 files changed, 23 insertions(+), 8 deletions(-) diff --git a/usr.sbin/pkg_install/info/info.h b/usr.sbin/pkg_install/info/info.h index 926ce2e..6554db5 100644 --- a/usr.sbin/pkg_install/info/info.h +++ b/usr.sbin/pkg_install/info/info.h @@ -62,7 +62,6 @@ struct which_entry { TAILQ_HEAD(which_head, which_entry); extern int Flags; -extern Boolean Quiet; extern Boolean QUIET; extern Boolean UseBlkSz; extern char *InfoPrefix; diff --git a/usr.sbin/pkg_install/info/main.c b/usr.sbin/pkg_install/info/main.c index a7bcfe2..d985938 100644 --- a/usr.sbin/pkg_install/info/main.c +++ b/usr.sbin/pkg_install/info/main.c @@ -30,7 +30,6 @@ static char Options[] = "abcdDe:EfgGhiIjkl:LmoO:pPqQrRst:vVW:xX"; int Flags = 0; match_t MatchType = MATCH_GLOB; -Boolean Quiet = FALSE; Boolean QUIET = FALSE; Boolean UseBlkSz = FALSE; char *InfoPrefix = (char *)(uintptr_t)""; diff --git a/usr.sbin/pkg_install/lib/global.c b/usr.sbin/pkg_install/lib/global.c index 291f48b..8e94f56 100644 --- a/usr.sbin/pkg_install/lib/global.c +++ b/usr.sbin/pkg_install/lib/global.c @@ -25,6 +25,7 @@ __FBSDID("$FreeBSD$"); #include "lib.h" /* These are global for all utils */ +Boolean Quiet = FALSE; Boolean Verbose = FALSE; Boolean Fake = FALSE; Boolean Force = FALSE; diff --git a/usr.sbin/pkg_install/lib/lib.h b/usr.sbin/pkg_install/lib/lib.h index c50a944..93e4c12 100644 --- a/usr.sbin/pkg_install/lib/lib.h +++ b/usr.sbin/pkg_install/lib/lib.h @@ -224,6 +224,7 @@ int verscmp(Package *, int, int); int version_cmp(const char *, const char *); /* Externs */ +extern Boolean Quiet; extern Boolean Verbose; extern Boolean Fake; extern Boolean Force; diff --git a/usr.sbin/pkg_install/version/main.c b/usr.sbin/pkg_install/version/main.c index 39ea37f..38ff320 100644 --- a/usr.sbin/pkg_install/version/main.c +++ b/usr.sbin/pkg_install/version/main.c @@ -25,7 +25,7 @@ __FBSDID("$FreeBSD$"); #include "version.h" #include -static char Options[] = "dhl:L:s:XtTv"; +static char Options[] = "dhl:L:qs:XtTv"; char *LimitChars = NULL; char *PreventChars = NULL; @@ -62,6 +62,10 @@ main(int argc, char **argv) PreventChars = optarg; break; + case 'q': + Quiet = TRUE; + break; + case 's': MatchName = optarg; break; diff --git a/usr.sbin/pkg_install/version/perform.c b/usr.sbin/pkg_install/version/perform.c index c1e952d..d5b817d 100644 --- a/usr.sbin/pkg_install/version/perform.c +++ b/usr.sbin/pkg_install/version/perform.c @@ -290,17 +290,17 @@ show_version(const char *installed, const char *latest, const char *source) ver = strrchr(latest, '-'); ver = ver ? &ver[1] : latest; if (cmp < 0 && OUTPUT('<')) { - printf("%-34s <", tmp); + printf("%-34s %c", tmp, Quiet ? '\0' : '<'); if (Verbose) printf(" needs updating (%s has %s)", source, ver); printf("\n"); } else if (cmp == 0 && OUTPUT('=')) { - printf("%-34s =", tmp); + printf("%-34s %c", tmp, Quiet ? '\0' : '='); if (Verbose) printf(" up-to-date with %s", source); printf("\n"); } else if (cmp > 0 && OUTPUT('>')) { - printf("%-34s >", tmp); + printf("%-34s %c", tmp, Quiet ? '\0' : '>'); if (Verbose) printf(" succeeds %s (%s has %s)", source, source, ver); printf("\n"); diff --git a/usr.sbin/pkg_install/version/pkg_version.1 b/usr.sbin/pkg_install/version/pkg_version.1 index 6ef25ae..ad71e6c 100644 --- a/usr.sbin/pkg_install/version/pkg_version.1 +++ b/usr.sbin/pkg_install/version/pkg_version.1 @@ -32,7 +32,7 @@ .Nd summarize installed versions of packages .Sh SYNOPSIS .Nm -.Op Fl hv +.Op Fl hqv .Op Fl l Ar limchar .Op Fl L Ar limchar .Oo @@ -137,6 +137,16 @@ 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 q +Enable quiet output. +Quiet output precludes printing the the +.Ar limchar +when used with +.Fl l +or +.Fl L . +This is useful when used as the input to +.Xr portupdate 8 . .It Fl s Limit the output to those packages whose names match a given .Ar string . @@ -194,7 +204,8 @@ option has been deprecated and is no longer supported. .Xr pkg_add 1 , .Xr pkg_create 1 , .Xr pkg_delete 1 , -.Xr pkg_info 1 +.Xr pkg_info 1 , +.Xr portupdate 8 .Sh FILES .Bl -tag -width /usr/ports/INDEX-5 -compact .It Pa /usr/ports/INDEX-5 -- cgit v1.1