From a119f96a73c1a3f7b58e1cfb74d364eef196dffc Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Wed, 3 Aug 2022 00:42:10 -0500 Subject: [PATCH] [buildcore] Cleanup pybb error handling and type annotations --- deps/buildcore/scripts/pybb.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/deps/buildcore/scripts/pybb.py b/deps/buildcore/scripts/pybb.py index 16d0b05a..76bc44b9 100755 --- a/deps/buildcore/scripts/pybb.py +++ b/deps/buildcore/scripts/pybb.py @@ -8,7 +8,7 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. # -# "Python Busy Box" - adds cross platform equivalents to Unix commands that +# "Python Busy Box" - adds cross-platform equivalents to Unix commands that # don't translate well to that other operating system import os @@ -17,7 +17,7 @@ import subprocess import sys -def cat(paths: str) -> int: +def cat(paths: [str]) -> int: for path in paths: try: with open(path) as f: @@ -109,11 +109,15 @@ def main(): err = cmake_build(sys.argv[2], sys.argv[3] if len(sys.argv) > 3 else None) elif sys.argv[1] == 'cat': err = cat(sys.argv[2:]) - sys.exit(err) + else: + sys.stderr.write('Command not found\n') + err = 1 + return err if __name__ == '__main__': try: - main() + err = main() + sys.exit(err) except KeyboardInterrupt: sys.exit(1)