wuyuoss / rpms / rpm

Forked from rpms/rpm 3 years ago
Clone
Blob Blame History Raw
From ce11f04ed529cd84de8981b82c1185c0a30dfdcf Mon Sep 17 00:00:00 2001
From: Pavlina Moravcova Varekova <pmoravco@redhat.com>
Date: Thu, 14 Mar 2019 13:23:13 +0100
Subject: [PATCH] Correct rpm -ql exit value when optional -p is omitted
 (RhBug:1680610)

---
 lib/query.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/query.c b/lib/query.c
index e47189ed0..e5408e211 100644
--- a/lib/query.c
+++ b/lib/query.c
@@ -568,16 +568,18 @@ int rpmcliArgIter(rpmts ts, QVA_t qva, ARGV_const_t argv)
 	break;
     default:
 	for (ARGV_const_t arg = argv; arg && *arg; arg++) {
+	    int ecLocal;
 	    rpmdbMatchIterator mi = initQueryIterator(qva, ts, *arg);
-	    ec += rpmcliShowMatches(qva, ts, mi);
+	    ecLocal = rpmcliShowMatches(qva, ts, mi);
 	    if (mi == NULL && qva->qva_source == RPMQV_PACKAGE) {
 		size_t l = strlen(*arg);
 		if (l > 4 && !strcmp(*arg + l - 4, ".rpm")) {
 		    rpmgi gi = rpmgiNew(ts, giFlags, argv);
-		    ec += rpmgiShowMatches(qva, ts, gi);
+		    ecLocal = rpmgiShowMatches(qva, ts, gi);
 		    rpmgiFree(gi);
 		}
 	    }
+	    ec += ecLocal;
 	    rpmdbFreeIterator(mi);
 	}
 	break;
-- 
2.17.2