diff options
author | eik <eik@FreeBSD.org> | 2004-06-29 18:54:47 +0000 |
---|---|---|
committer | eik <eik@FreeBSD.org> | 2004-06-29 18:54:47 +0000 |
commit | 7923356ae6b0c5daf724f0e5c8844ffec1bb4871 (patch) | |
tree | 96259c70ed86c0b116099b99afb26ba9fecc746e /usr.sbin/pkg_install/info/perform.c | |
parent | 649576111eab9cebc8bcde1eb574a9f3644fe2a6 (diff) | |
download | FreeBSD-src-7923356ae6b0c5daf724f0e5c8844ffec1bb4871.zip FreeBSD-src-7923356ae6b0c5daf724f0e5c8844ffec1bb4871.tar.gz |
- match package version numbers with relational operators
- use glob patterns when matching packages by origin
- csh-style {...} choices in glob matching
- pkg_info: new flag -E (list matching package names only)
- pkg_version: new flag -T (test if a given name matches a pattern)
- new flag -X (interpret pattern as an extended regular expression)
PR: 56961
Diffstat (limited to 'usr.sbin/pkg_install/info/perform.c')
-rw-r--r-- | usr.sbin/pkg_install/info/perform.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/usr.sbin/pkg_install/info/perform.c b/usr.sbin/pkg_install/info/perform.c index f45f7c7..5511f41 100644 --- a/usr.sbin/pkg_install/info/perform.c +++ b/usr.sbin/pkg_install/info/perform.c @@ -31,6 +31,7 @@ static int find_pkg(struct which_head *); static int cmp_path(const char *, const char *, const char *); static char *abspath(const char *); static int find_pkgs_by_origin(const char *); +static int matched_packages(char **pkgs); int pkg_perform(char **pkgs) @@ -42,7 +43,9 @@ pkg_perform(char **pkgs) signal(SIGINT, cleanup); /* Overriding action? */ - if (CheckPkg) { + if (Flags & SHOW_PKGNAME) { + return matched_packages(pkgs); + } else if (CheckPkg) { return isinstalledpkg(CheckPkg) == TRUE ? 0 : 1; /* Not reached */ } else if (!TAILQ_EMPTY(whead)) { @@ -67,6 +70,7 @@ pkg_perform(char **pkgs) return 0; /* Not reached */ case MATCH_REGEX: + case MATCH_EREGEX: warnx("no packages match pattern(s)"); return 1; /* Not reached */ @@ -451,3 +455,27 @@ find_pkgs_by_origin(const char *origin) return 0; } + +/* + * List only the matching package names. + * Mainly intended for scripts. + */ +static int +matched_packages(char **pkgs) +{ + char **matched; + int i, errcode; + + matched = matchinstalled(MatchType == MATCH_GLOB ? MATCH_NGLOB : MatchType, pkgs, &errcode); + + if (errcode != 0 || matched == NULL) + return 1; + + for (i = 0; matched[i]; i++) + if (!Quiet) + printf("%s\n", matched[i]); + else if (QUIET) + printf("%s%s\n", InfoPrefix, matched[i]); + + return 0; +} |