From a5d4a8a92688d2d971d00cdc3201eb552bebca50 Mon Sep 17 00:00:00 2001 From: Lars Karlitski Date: Tue, 27 Oct 2020 10:18:14 +0100 Subject: [PATCH] osbuild: always return exit code osbuild_cli() sometimes returned an exit code, but at the end called sys.exit() directly. The idea was probably to always return the code with which the executable should exit. Make this consistent and call sys.exit() in __main__.py, with the value returned by osbuild_cli(). --- osbuild/__main__.py | 4 +++- osbuild/main_cli.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/osbuild/__main__.py b/osbuild/__main__.py index 7d0c70f4..f5275b01 100755 --- a/osbuild/__main__.py +++ b/osbuild/__main__.py @@ -4,9 +4,11 @@ This specifies the entrypoint of the osbuild module when run as executable. For compatibility we will continue to run the CLI. """ +import sys from osbuild.main_cli import osbuild_cli as main if __name__ == "__main__": - main() + r = main() + sys.exit(r) diff --git a/osbuild/main_cli.py b/osbuild/main_cli.py index dba0d45b..acd19d72 100644 --- a/osbuild/main_cli.py +++ b/osbuild/main_cli.py @@ -172,4 +172,4 @@ def osbuild_cli(): print() print(f"{RESET}{BOLD}{RED}Failed{RESET}") - sys.exit(0 if r["success"] else 1) + return 0 if r["success"] else 1