summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2007-05-31 07:12:17 +0200
committerDan McGee <dan@archlinux.org>2007-05-31 07:12:17 +0200
commit722db4535ae6690d8834ffebf3a0de3a880188f9 (patch)
treec58d84cc25232eba713bcc22f3a678d1e76a20e9
parentcad44221c811af0c528589bd087531f8ece6257e (diff)
downloadpacman-722db4535ae6690d8834ffebf3a0de3a880188f9.tar.gz
pacman-722db4535ae6690d8834ffebf3a0de3a880188f9.tar.xz
Set an error exit status on -Qi or -Si failure
Regression from 2.9.8 where a failed -Qi lookup did not return an error on exit. The exit status is now incremented for each error encountered. Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--src/pacman/query.c28
-rw-r--r--src/pacman/sync.c5
2 files changed, 15 insertions, 18 deletions
diff --git a/src/pacman/query.c b/src/pacman/query.c
index 4abb674d..57850e8f 100644
--- a/src/pacman/query.c
+++ b/src/pacman/query.c
@@ -120,14 +120,14 @@ int pacman_query(alpm_list_t *targets)
alpm_list_t *sync_dbs = NULL, *i, *j, *k;
pmpkg_t *info = NULL;
char *package = NULL;
- int done = 0;
+ int ret = 0;
if(config->op_q_search) {
- alpm_list_t *ret = alpm_db_search(db_local, targets);
- if(ret == NULL) {
+ alpm_list_t *searchlist = alpm_db_search(db_local, targets);
+ if(searchlist == NULL) {
return(0);
}
- for(i = ret; i; i = alpm_list_next(i)) {
+ for(i = searchlist; i; i = alpm_list_next(i)) {
char *group = NULL;
alpm_list_t *grp;
pmpkg_t *pkg = alpm_list_getdata(i);
@@ -154,7 +154,7 @@ int pacman_query(alpm_list_t *targets)
indentprint(alpm_pkg_get_desc(pkg), 4);
printf("\n");
}
- alpm_list_free(ret);
+ alpm_list_free(searchlist);
return(0);
}
@@ -180,15 +180,8 @@ int pacman_query(alpm_list_t *targets)
}
}
- for(i = targets; !done; i = (i ? alpm_list_next(i) : NULL)) {
- if(targets == NULL) {
- done = 1;
- } else {
- if(alpm_list_next(i) == NULL) {
- done = 1;
- }
- package = alpm_list_getdata(i);
- }
+ for(i = targets; i; i = alpm_list_next(i)) {
+ package = alpm_list_getdata(i);
/* looking for groups */
if(config->group) {
@@ -214,8 +207,7 @@ int pacman_query(alpm_list_t *targets)
}
} else {
fprintf(stderr, _("error: group \"%s\" was not found\n"), package);
- /* do not return on query operations - let's just carry on */
- /*return(2);*/
+ ret++;
}
}
continue;
@@ -268,6 +260,7 @@ int pacman_query(alpm_list_t *targets)
if(info == NULL) {
/* something weird happened */
fprintf(stderr, _("error: package \"%s\" not found\n"), pkgname);
+ ret++;
continue;
}
}
@@ -301,6 +294,7 @@ int pacman_query(alpm_list_t *targets)
info = alpm_db_get_pkg(db_local, package);
if(info == NULL) {
fprintf(stderr, _("error: package \"%s\" not found\n"), package);
+ ret++;
continue;
}
@@ -327,7 +321,7 @@ int pacman_query(alpm_list_t *targets)
}
}
- return(0);
+ return(ret);
}
/* vim: set ts=2 sw=2 noet: */
diff --git a/src/pacman/sync.c b/src/pacman/sync.c
index 4f11bb4c..f013d45f 100644
--- a/src/pacman/sync.c
+++ b/src/pacman/sync.c
@@ -325,6 +325,7 @@ static int sync_group(int level, alpm_list_t *syncs, alpm_list_t *targets)
static int sync_info(alpm_list_t *syncs, alpm_list_t *targets)
{
alpm_list_t *i, *j, *k;
+ int ret = 0;
if(targets) {
for(i = targets; i; i = alpm_list_next(i)) {
@@ -367,6 +368,7 @@ static int sync_info(alpm_list_t *syncs, alpm_list_t *targets)
if(!foundpkg) {
fprintf(stderr, _("error: package '%s' was not found in repository '%s'\n"), pkgstr, repo);
+ ret++;
}
} else {
pkgstr = target;
@@ -387,6 +389,7 @@ static int sync_info(alpm_list_t *syncs, alpm_list_t *targets)
}
if(!foundpkg) {
fprintf(stderr, _("error: package '%s' was not found\n"), pkgstr);
+ ret++;
}
}
}
@@ -401,7 +404,7 @@ static int sync_info(alpm_list_t *syncs, alpm_list_t *targets)
}
}
- return(0);
+ return(ret);
}
static int sync_list(alpm_list_t *syncs, alpm_list_t *targets)