From: Ashley Whetter <awhetter.2011@my.bristol.ac.uk> Non-zero is now returned if a group is searched for that doesn't exist Fixes FS#36097 Signed-off-by: Ashley Whetter <awhetter.2011@my.bristol.ac.uk> --- The only changes in this version are the one's recommended by Allan. 'found' is now called 'ret' and 'found_in_db' is now called 'found'. 'found_in_db' (now 'found') is initialised in the 'if (targets)' condition. src/pacman/sync.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/pacman/sync.c b/src/pacman/sync.c index fc1314b..e211f7b 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -367,8 +367,10 @@ 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 = 0; for(i = targets; i; i = alpm_list_next(i)) { const char *grpname = i->data; for(j = syncs; j; j = alpm_list_next(j)) { @@ -376,6 +378,7 @@ static int sync_group(int level, alpm_list_t *syncs, alpm_list_t *targets) 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 +390,19 @@ static int sync_group(int level, alpm_list_t *syncs, alpm_list_t *targets) } } } + if (!found) { + ret = 1; + } + found = 0; } } 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) -- 1.8.3.3