From 365c3eaf4b35c0e23bcc72e8531f8903f844e037 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 5 Feb 2020 15:31:32 +0200 Subject: [PATCH] Fixed an issue when invalid CLI command does not return non-zero exit code --- HISTORY.rst | 1 + platformio/__main__.py | 5 +++-- tests/package/test_manifest.py | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index dcf46aa0..14a32bfc 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -32,6 +32,7 @@ PlatformIO Core 4.0 * Fixed default PIO Unified Debugger configuration for `J-Link probe `__ * Fixed an issue with LDF when header files not found if "libdeps_dir" is within a subdirectory of "lib_extra_dirs" (`issue #3311 `_) * Fixed an issue "Import of non-existent variable 'projenv''" when development platform does not call "env.BuildProgram()" (`issue #3315 `_) +* Fixed an issue when invalid CLI command does not return non-zero exit code 4.1.0 (2019-11-07) ~~~~~~~~~~~~~~~~~~ diff --git a/platformio/__main__.py b/platformio/__main__.py index 043befbd..6679d52e 100644 --- a/platformio/__main__.py +++ b/platformio/__main__.py @@ -100,8 +100,9 @@ def main(argv=None): try: configure() cli() # pylint: disable=no-value-for-parameter - except SystemExit: - pass + except SystemExit as e: + if e.code and str(e.code).isdigit(): + exit_code = int(e.code) except Exception as e: # pylint: disable=broad-except if not isinstance(e, exception.ReturnErrorCode): maintenance.on_platformio_exception(e) diff --git a/tests/package/test_manifest.py b/tests/package/test_manifest.py index 74d0aa3e..54b16c2f 100644 --- a/tests/package/test_manifest.py +++ b/tests/package/test_manifest.py @@ -69,7 +69,7 @@ def test_library_json_parser(): {"name": "deps2", "version": "https://github.com/username/package.git"}, ], "customField": "Custom Value", - } + }, ) contents = """