This patch changes the exit code to indicate failure when people do:

 yum list FOO

...and FOO doesn't exist. I've attached it and it can be merged from:

git pull http://people.redhat.com/jantill/gits/yum yum-list-cmd-exit

 Or all my current patches can be merged from:

git pull http://people.redhat.com/jantill/gits/yum james

-- 
James Antill <[EMAIL PROTECTED]>
diff --git a/output.py b/output.py
index 2d8b6c4..6f02ccc 100644
--- a/output.py
+++ b/output.py
@@ -105,6 +105,7 @@ class YumOutput:
     
             if thingslisted == 0:
                 return 1, ['No Packages to list']
+            return 0, []
         
     
         
diff --git a/yumcommands.py b/yumcommands.py
index 35cfd67..cc47562 100644
--- a/yumcommands.py
+++ b/yumcommands.py
@@ -161,18 +161,25 @@ class InfoCommand(YumCommand):
         except yum.Errors.YumBaseError, e:
             return 1, [str(e)]
         else:
-            base.listPkgs(ypl.installed, 'Installed Packages', basecmd)
-            base.listPkgs(ypl.available, 'Available Packages', basecmd)
-            base.listPkgs(ypl.extras, 'Extra Packages', basecmd)
-            base.listPkgs(ypl.updates, 'Updated Packages', basecmd)
+            rip = base.listPkgs(ypl.installed, 'Installed Packages', basecmd)
+            rap = base.listPkgs(ypl.available, 'Available Packages', basecmd)
+            rep = base.listPkgs(ypl.extras, 'Extra Packages', basecmd)
+            rup = base.listPkgs(ypl.updates, 'Updated Packages', basecmd)
             if len(ypl.obsoletes) > 0 and basecmd == 'list': 
             # if we've looked up obsolete lists and it's a list request
+                rop = [0, '']
                 print 'Obsoleting Packages'
                 for obtup in ypl.obsoletesTuples:
                     base.updatesObsoletesList(obtup, 'obsoletes')
             else:
-                base.listPkgs(ypl.obsoletes, 'Obsoleting Packages', basecmd)
-            base.listPkgs(ypl.recent, 'Recently Added Packages', basecmd)
+                rop = base.listPkgs(ypl.obsoletes, 'Obsoleting Packages', basecmd)
+            rrap = base.listPkgs(ypl.recent, 'Recently Added Packages', basecmd)
+            # extcmds is pop(0)'d if they pass a "special" param like "updates"
+            # in returnPkgLists(). This allows us to always return "ok" for
+            # things like "yum list updates".
+            if len(extcmds) and \
+               rrap[0] and rop[0] and rup[0] and rep[0] and rap[0] and rip[0]:
+                return 1, ['No matching Packages to list']
             return 0, []
 
 class EraseCommand(YumCommand):

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
Yum-devel mailing list
[email protected]
https://lists.dulug.duke.edu/mailman/listinfo/yum-devel

Reply via email to