diff options
author | sobomax <sobomax@FreeBSD.org> | 2001-02-27 09:00:18 +0000 |
---|---|---|
committer | sobomax <sobomax@FreeBSD.org> | 2001-02-27 09:00:18 +0000 |
commit | 9ef21beb7a0f2e40841eaec959a3353bb1a0fab1 (patch) | |
tree | e3f9b793ac5867f8c854408a2545d3e05f9e0df5 /usr.sbin/pkg_install/delete/perform.c | |
parent | 3dba1d1543776a0f641cde330672fdb902764a4b (diff) | |
download | FreeBSD-src-9ef21beb7a0f2e40841eaec959a3353bb1a0fab1.zip FreeBSD-src-9ef21beb7a0f2e40841eaec959a3353bb1a0fab1.tar.gz |
- Merge recently added into pkg_info(1) regex/glob matching functionality into
pkg_delete(1) as well;
- add a new `-a' option for pkg_delete(1) to delete all installed packages;
- add a new `-i' option for pkg_delete(1) to request simple rm(1)-like
interactive confirmation before attempting to delete each package.
Silently approved by: jkh, -ports
Diffstat (limited to 'usr.sbin/pkg_install/delete/perform.c')
-rw-r--r-- | usr.sbin/pkg_install/delete/perform.c | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/usr.sbin/pkg_install/delete/perform.c b/usr.sbin/pkg_install/delete/perform.c index 072b6d5..3453cf8 100644 --- a/usr.sbin/pkg_install/delete/perform.c +++ b/usr.sbin/pkg_install/delete/perform.c @@ -37,10 +37,33 @@ static char LogDir[FILENAME_MAX]; int pkg_perform(char **pkgs) { + char **matched; char *tmp; int i, j; int err_cnt = 0; - int loop_cnt; + int loop_cnt, errcode; + + if (MatchType != MATCH_EXACT) { + matched = matchinstalled(MatchType, pkgs, &errcode); + if (errcode != 0) + return 1; + /* Not reached */ + + if (matched != NULL) + pkgs = matched; + else switch (MatchType) { + case MATCH_GLOB: + break; + case MATCH_ALL: + warnx("no packages installed"); + return 0; + case MATCH_REGEX: + warnx("no packages match pattern(s)"); + return 1; + default: + break; + } + } for (i = 0; pkgs[i]; i++) { /* @@ -122,6 +145,19 @@ pkg_do(char *pkg) return 1; } + if (Interactive == TRUE) { + int first, ch; + + (void)fprintf(stderr, "delete %s? ", pkg); + (void)fflush(stderr); + first = ch = getchar(); + while (ch != '\n' && ch != EOF) + ch = getchar(); + if (first != 'y' && first != 'Y') + return 0; + /* Not reached */ + } + if (!isemptyfile(REQUIRED_BY_FNAME)) { char buf[512]; warnx("package `%s' is required by these other packages\n" |