Add a -q flag to pkg_version. It suppresses the output of <,=,>.

This makes it possible to "portupgrade `pkg_version -q -l '<'`".
This commit is contained in:
David E. O'Brien 2004-10-18 05:34:54 +00:00
parent d4ddb4f67f
commit f4a324ac51
7 changed files with 23 additions and 8 deletions

View File

@ -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;

View File

@ -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)"";

View File

@ -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;

View File

@ -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;

View File

@ -25,7 +25,7 @@ __FBSDID("$FreeBSD$");
#include "version.h"
#include <err.h>
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;

View File

@ -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");

View File

@ -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