From 6e3ea82f9bd88fc12efbb6da24e2b52ca3cf9819 Mon Sep 17 00:00:00 2001 From: Ashley Whetter Date: Tue, 16 Jul 2013 10:18:32 +0100 Subject: Corrected return codes for Sg flag Non-zero is now returned if a group is searched for that doesn't exist. Fixes FS#36097. Signed-off-by: Ashley Whetter Signed-off-by: Allan McRae --- src/pacman/sync.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/pacman/sync.c b/src/pacman/sync.c index fc1314be..942f7654 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -367,15 +367,19 @@ static int sync_search(alpm_list_t *syncs, alpm_list_t *targets) static int sync_group(int level, alpm_list_t *syncs, alpm_list_t *targets) { alpm_list_t *i, *j, *k, *s = NULL; + int ret = 0; if(targets) { + int found; for(i = targets; i; i = alpm_list_next(i)) { + found = 0; const char *grpname = i->data; for(j = syncs; j; j = alpm_list_next(j)) { alpm_db_t *db = j->data; alpm_group_t *grp = alpm_db_get_group(db, grpname); if(grp) { + found++; /* get names of packages in group */ for(k = grp->packages; k; k = alpm_list_next(k)) { if(!config->quiet) { @@ -387,13 +391,18 @@ static int sync_group(int level, alpm_list_t *syncs, alpm_list_t *targets) } } } + if (!found) { + ret = 1; + } } } else { + ret = 1; for(i = syncs; i; i = alpm_list_next(i)) { alpm_db_t *db = i->data; for(j = alpm_db_get_groupcache(db); j; j = alpm_list_next(j)) { alpm_group_t *grp = j->data; + ret = 0; if(level > 1) { for(k = grp->packages; k; k = alpm_list_next(k)) { @@ -412,7 +421,7 @@ static int sync_group(int level, alpm_list_t *syncs, alpm_list_t *targets) alpm_list_free(s); } - return 0; + return ret; } static int sync_info(alpm_list_t *syncs, alpm_list_t *targets) -- cgit v1.2.3-24-g4f1b