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>
This commit is contained in:
Dan McGee 2007-05-31 01:12:17 -04:00
parent cad44221c8
commit 722db4535a
2 changed files with 15 additions and 18 deletions

View file

@ -120,14 +120,14 @@ int pacman_query(alpm_list_t *targets)
alpm_list_t *sync_dbs = NULL, *i, *j, *k; alpm_list_t *sync_dbs = NULL, *i, *j, *k;
pmpkg_t *info = NULL; pmpkg_t *info = NULL;
char *package = NULL; char *package = NULL;
int done = 0; int ret = 0;
if(config->op_q_search) { if(config->op_q_search) {
alpm_list_t *ret = alpm_db_search(db_local, targets); alpm_list_t *searchlist = alpm_db_search(db_local, targets);
if(ret == NULL) { if(searchlist == NULL) {
return(0); return(0);
} }
for(i = ret; i; i = alpm_list_next(i)) { for(i = searchlist; i; i = alpm_list_next(i)) {
char *group = NULL; char *group = NULL;
alpm_list_t *grp; alpm_list_t *grp;
pmpkg_t *pkg = alpm_list_getdata(i); 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); indentprint(alpm_pkg_get_desc(pkg), 4);
printf("\n"); printf("\n");
} }
alpm_list_free(ret); alpm_list_free(searchlist);
return(0); return(0);
} }
@ -180,15 +180,8 @@ int pacman_query(alpm_list_t *targets)
} }
} }
for(i = targets; !done; i = (i ? alpm_list_next(i) : NULL)) { for(i = targets; i; i = alpm_list_next(i)) {
if(targets == NULL) { package = alpm_list_getdata(i);
done = 1;
} else {
if(alpm_list_next(i) == NULL) {
done = 1;
}
package = alpm_list_getdata(i);
}
/* looking for groups */ /* looking for groups */
if(config->group) { if(config->group) {
@ -214,8 +207,7 @@ int pacman_query(alpm_list_t *targets)
} }
} else { } else {
fprintf(stderr, _("error: group \"%s\" was not found\n"), package); fprintf(stderr, _("error: group \"%s\" was not found\n"), package);
/* do not return on query operations - let's just carry on */ ret++;
/*return(2);*/
} }
} }
continue; continue;
@ -268,6 +260,7 @@ int pacman_query(alpm_list_t *targets)
if(info == NULL) { if(info == NULL) {
/* something weird happened */ /* something weird happened */
fprintf(stderr, _("error: package \"%s\" not found\n"), pkgname); fprintf(stderr, _("error: package \"%s\" not found\n"), pkgname);
ret++;
continue; continue;
} }
} }
@ -301,6 +294,7 @@ int pacman_query(alpm_list_t *targets)
info = alpm_db_get_pkg(db_local, package); info = alpm_db_get_pkg(db_local, package);
if(info == NULL) { if(info == NULL) {
fprintf(stderr, _("error: package \"%s\" not found\n"), package); fprintf(stderr, _("error: package \"%s\" not found\n"), package);
ret++;
continue; continue;
} }
@ -327,7 +321,7 @@ int pacman_query(alpm_list_t *targets)
} }
} }
return(0); return(ret);
} }
/* vim: set ts=2 sw=2 noet: */ /* vim: set ts=2 sw=2 noet: */

View file

@ -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) static int sync_info(alpm_list_t *syncs, alpm_list_t *targets)
{ {
alpm_list_t *i, *j, *k; alpm_list_t *i, *j, *k;
int ret = 0;
if(targets) { if(targets) {
for(i = targets; i; i = alpm_list_next(i)) { 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) { if(!foundpkg) {
fprintf(stderr, _("error: package '%s' was not found in repository '%s'\n"), pkgstr, repo); fprintf(stderr, _("error: package '%s' was not found in repository '%s'\n"), pkgstr, repo);
ret++;
} }
} else { } else {
pkgstr = target; pkgstr = target;
@ -387,6 +389,7 @@ static int sync_info(alpm_list_t *syncs, alpm_list_t *targets)
} }
if(!foundpkg) { if(!foundpkg) {
fprintf(stderr, _("error: package '%s' was not found\n"), pkgstr); 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) static int sync_list(alpm_list_t *syncs, alpm_list_t *targets)