]> git.ipfire.org Git - pakfire.git/commitdiff
pakfire: Don't throw an exception if execute fails
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 8 Dec 2021 18:57:10 +0000 (18:57 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 8 Dec 2021 18:57:10 +0000 (18:57 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/scripts/pakfire.in

index b77698e08a2425a3c4ec3dd7362a8d29d7eae6f1..fdd21f26a85f40399dd5859c378c86651c54ba07 100644 (file)
@@ -24,6 +24,7 @@ import logging
 import sys
 
 import pakfire
+import pakfire.errors
 from pakfire.i18n import _
 
 class Cli(object):
@@ -316,8 +317,13 @@ class Cli(object):
                        else:
                                sys.stdout.write("%s\n" % line)
 
-               return p.execute(args.command,
-                       interactive=args.interactive, logging_callback=logging_callback)
+               try:
+                       return p.execute(args.command,
+                               interactive=args.interactive, logging_callback=logging_callback)
+
+               # Exit program with the command's exit code
+               except pakfire.errors.CommandExecutionError as e:
+                       return e.args[0]
 
        def _info(self, p, args):
                for pkg in p.search(args.package, name_only=True):